IOS笔记 : 一些小技巧_移动开发_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > 移动开发 > IOS笔记 : 一些小技巧

IOS笔记 : 一些小技巧

 2015/1/31 11:06:03  lgphp  程序员俱乐部  我要评论(0)
  • 摘要:计算单元格高度,在自定义cell中-(void)resizeTheHeight{CGFloatcontentWidth=280;UIFont*font=[UIFontfontWithName:@"Arial"size:14];CGSizesize=[txtContent.textsizeWithFont:fontconstrainedToSize:CGSizeMake(contentWidth,220)lineBreakMode:UILineBreakModeTailTruncation]
  • 标签:笔记 iOS 技巧

计算单元格高度,在自定义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"];
}

上一篇: Android 中的缓存机制与实现 下一篇: 没有下一篇了!
发表评论
用户名: 匿名