KVO


值变化刷新界面

//注册调用
[testPerson addObserver:self forKeyPath:@"height" options:NSKeyValueObservingOptionNew context:nil]; 
 
//回调函数
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context  
{  
    if ([keyPath isEqualToString:@"height"]) {  
        NSLog(@"Height is changed! new=%@", [change valueForKey:NSKeyValueChangeNewKey]);  
    } else {  
        [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];  
    }  
}  

UIScrollView


- (void) setup{
    //scrollview
    self.scrollView.delegate = self;
    int imagecount = 4;
    self.scrollView.contentSize = CGSizeMake(imagecount * PKScreenW, 0);
    self.scrollView.bounces = NO;
    //回弹
    self.scrollView.showsHorizontalScrollIndicator = NO;
    //分页
    self.scrollView.pagingEnabled = YES;
    
    //添加图片 到 scrollView
    int imageW = PKScreenW;
    for (int i = 0; i < imagecount; i++) {
        NSString *imagename = @"Starting_Image";//[NSString stringWithFormat:@"%d", i + 1];
        UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imagename]];
        image.userInteractionEnabled = YES;
        image.size = CGSizeMake(PKScreenW, PKScreenH-PKNavigationH);
        PKLog(@"%f,%f",self.size.width,self.size.height);
        image.x = i * imageW;
        image.y = 0;
        [self.scrollView addSubview:image];
    }
    
    //page num
    self.pageNum.currentPageIndicatorTintColor = PKGlobalBg;
    self.pageNum.pageIndicatorTintColor = PKDividingLineColor;
    self.pageNum.numberOfPages = imagecount;
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    self.pageNum.currentPage = scrollView.contentOffset.x/self.width+0.5;
}

下拉菜单 PKDropdownView


公司自定义类

//初始化
self.downView = [[PKDropdownView alloc] initWithFrame:CGRectMake(screenBounds.size.width-self.toolClickView.width-100, y-25, 112, 112)];
self.downView.titleArray = @[@"发私信", @"举报"];
self.downView.delegate = self;

//代理
/** button 请用tag判断 1代表第一个按钮,以此类推 */
- (void)PKDropdownView:(PKDropdownView *)dropdownView didClickButton:(UIButton *)button;
@end

获取相册全部内容


#import<AssetsLibrary/AssetsLibrary.h>

ALAssetsGroupEnumerationResultsBlock groupEnumerAtion = ^(ALAsset *result,NSUInteger index, BOOL *stop){
	if (result!=NULL) {     
		if ([[result valueForProperty:ALAssetPropertyType]isEqualToString:ALAssetTypePhoto]) {
			//图片URL
			NSString *urlstr=[NSString stringWithFormat:@"%@",result.defaultRepresentation.url];
			//图片的大图
			//result.defaultRepresentation.fullScreenImage
			//图片的缩略图小图
			//result.thumbnail                            
			[self.dataArray addObject:urlstr];
			}
}

获取相册分卷


ALAssetsLibraryGroupsEnumerationResultsBlock 
	libraryGroupsEnumeration = ^(ALAssetsGroup* group,BOOL* stop){            
            if (group == nil) 
            {
                
            }            
            if (group!=nil) {
                NSString *g=[NSString stringWithFormat:@"%@",group];//获取相簿的组
               NSLog(@"gg:%@",g);//gg:ALAssetsGroup - Name:Camera Roll, Type:Saved Photos, Assets count:71
                NSString *g1=[g substringFromIndex:16 ] ;
                NSArray *arr=[NSArray arrayWithArray:[g1 componentsSeparatedByString:@","]];
                NSString *g2=[[arr objectAtIndex:0]substringFromIndex:5];
                if ([g2 isEqualToString:@"Camera Roll"]) {
                    g2=@"相机胶卷";
                }
                NSString *groupName=g2;//组的name                
                [groupenumerateAssetsUsingBlock:groupEnumerAtion];
            }
            
        };