IOS笔记:一些小技巧

王朝学院·作者佚名  2016-08-27
窄屏简体版  字體: 小  |  中  |  大  |  超大  

计算单元格高度,在自定义cell中

-(void) resizeTheHeight

{

CGFloat contentWidth = 280;

UIFont *font = [UIFont fontWithName:@"Arial" size:14];

CGSize size = [txtContent.text sizeWithFont:font constrainedToSize:CGSizeMake(contentWidth, 220) lineBreakMode:UILineBreakModeTailTruncation];

[txtContent setFrame:CGRectMake(20, 28, 280, size.height)];

[centerimageView setFrame:CGRectMake(0, 0, 320, size.height+30)];

[footView setFrame:CGRectMake(5, size.height+28, 310, 2)];

}

id image = [dictionary objectForKey:@"image"];

if ((NSNull *)image != [NSNull null]) //判断是否为空

{

self.imageURL = [dictionary objectForKey:@"image"];

NSString *newImageURL = [NSString stringWithFormat:@"http://img.qiushibaike.com/system/pictures/%@/small/%@",qiushiID,imageURL];

NSString *newImageMidURL = [NSString stringWithFormat:@"http://img.qiushibaike.com/system/pictures/%@/medium/%@",qiushiID,imageURL];

self.imageURL = newImageURL;

self.imageMidURL = newImageMidURL;

}

NSDictionary *vote = [NSDictionary dictionaryWithDictionary:[dictionary objectForKey:@"votes"]];

self.downCount = [[vote objectForKey:@"down"]intValue];

self.upCount = [[vote objectForKey:@"up"]intValue];

id user = [dictionary objectForKey:@"user"];

if ((NSNull *)user != [NSNull null])

{

NSDictionary *user = [NSDictionary dictionaryWithDictionary:[dictionary objectForKey:@"user"]];

self.anchor = [user objectForKey:@"login"];

}

 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝網路 版權所有 導航