【发布时间】:2011-12-01 06:28:35
【问题描述】:
我正在尝试在特定 indexPath.row 处减小单元格的一个标签的宽度,但它不起作用.. 下面我为此添加了代码,我正在使用 iOs 5 故事板。 任何人都有其他方法可以在运行时更改标签的大小??
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"name&email"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
UILabel *nameLabel = (UILabel *)[cell viewWithTag:100];
UILabel *detail = (UILabel *)[cell viewWithTag:101];
if(indexPath.row == 0){
nameLabel.text = @"Name : ";
detail.text = @"";
}else if(indexPath.row == 1){
nameLabel.text = @"Email : ";
detail.text = @"";
}else if(indexPath.row == 2){
nameLabel.text = @"Location Alerts";
detail.text = @"Notifies people when they are close to a saved spot";
// here i am changing the width of lable
detail.frame = CGRectMake(0, 0, 100, 0);
}else if(indexPath.row == 3){
nameLabel.text = @"Share This App :";
detail.text = @"(post to facebook/twitter)";
}else if(indexPath.row == 4){
nameLabel.text = @"Review This App :";
detail.text = @"(on iTunes)";
}else if(indexPath.row == 5){
nameLabel.text = @"Get Help :";
detail.text = @"(send an email to me)";
}
// Configure the cell...
return cell;
}
【问题讨论】:
标签: uitableview ios5 uilabel