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"];
}

转载于:https://www.cnblogs.com/lgphp/p/4263677.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值