一:IOS7 cell 高度自适应
-(float)getHeight:(NSString *)text
{
if (self.interfaceOrientation == UIDeviceOrientationPortrait || self.interfaceOrientation == UIDeviceOrientationPortraitUpsideDown)
{
//正
CGRect rect=[text boundingRectWithSize:CGSizeMake(screen_w, 1000) options:NSStringDrawingUsesLineFragmentOrigin
attributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:12],NSFontAttributeName, nil] context:nil];
float x=rect.size.height;
return x+20;
}
else
{
//反
CGRect rect=[text boundingRectWithSize:CGSizeMake(screen_h, 1000) options:NSStringDrawingUsesLineFragmentOrigin
attributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:12],NSFontAttributeName, nil] context:nil];
float x=rect.size.height;
return x+20;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
CGSize size = [self.str sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake(320, 10000)];
return size.height+20;
}