代码改变世界

ios中常用的方法

2013-06-28 18:19  甘超波  阅读(748)  评论(0编辑  收藏  举报
图片分类

@implementation UIImageView (ext)

 

 

+(UIImageView*)imageViewWith:(UIImage*)img imgFrame:(CGRect)_rect{

    UIImageView *imgView = [[[UIImageViewalloc] initWithFrame:_rect] autorelease];

    imgView.image = img;

    return imgView;

}

//图片拉绳 

+ (UIImageView *)imageViewForResizableImage:(UIImage *)image inRect:(CGRect)rect

{

    UIImageView *imageView = [[[UIImageViewalloc] initWithFrame:rect] autorelease];

    imageView.userInteractionEnabled = YES;

    if ([image respondsToSelector:@selector(resizableImageWithCapInsets:)]) {

        imageView.image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(image.size.height/2, image.size.width/2, image.size.height/2, image.size.width/2)];

    } else {

        imageView.image = [image stretchableImageWithLeftCapWidth:image.size.width/2 topCapHeight:image.size.height/2];

    }

    return imageView;

}

 

 

@end
用block快速创建一个block 

+(XPNetWork*)shareNetWork{
    static XPNetWork *network = NULL;
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        network = [[self alloc] init];
    });
    return network;
}

UITableviewCell进行分组的
一个集合(NSArrary)包含多个个集合(NSArray  addobject:nsarrary]。section
一个集合包含 多个字典( nsarrary add object :字典】 row

赋值的时候

//self.mydata是最大集合
NSArray *sectionArray=self.mydata[indexPath.section];//得到组 section
NSDictionary *resDic=sectionArray[indexPath.row];//得到row.
//通过字典进行赋值。
NSString *keySt = [NSString stringWithFormat:@"%@:",[[resDic allKeys] objectAtIndex:0]];
                NSString *valueSt = [[resDic allValues] objectAtIndex:0];