#pragma mark
#pragma mark tableView delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPat
{
static NSString * identifier = @"default";
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
cell = [[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:identifier];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
}
cell.textLabel.font = [UIFont fontWithName:@"arial" size:15];
cell.textLabel.numberOfLines = 0;
cell.textLabel.text = self.description;
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
/*根据数据(self.description)得到数据大小. 然后用设置字的大小(sizeWithFont:).
*再判断是iPhone还是iPad.设置宽度(isPhone?300:950). 然后设置高度(CGFLOAT_MAX).
*/
CGSize requiredSize = [self.descriptionsizeWithFont:[UIFontsystemFontOfSize:15] constrainedToSize:CGSizeMake(isPhone?300:950, CGFLOAT_MAX) lineBreakMode:UILineBreakModeWordWrap];
return requiredSize.height+20;
}