0
我正在嘗試爲我們的應用程序創建一個設置。我不確定這裏發生了什麼。我有一個UITableViewSyleGrouped,並在表的每個部分,有1行。對於我的特定行,它顯示了該人的姓名。如果你點擊它,然後它推到一個新的tableView,它有可供選擇的人員列表,然後當你彈出時,標籤被更新,但是當我從一個較小的名字轉到一個更大的名字時,標籤被截斷。我正在嘗試爲我們的應用創建一個設置。一些字段如下所示:cell.textLabel沒有調整大小
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger row = [indexPath row];
if (tableView == _settingsTableView) {
UITableViewCell *cell = nil;
NSNumber *aSection = [_tableArray objectAtIndex:indexPath.section];
if ([aSection integerValue] == SOUNDS)
{
cell = [tableView dequeueReusableCellWithIdentifier:@"SwitchCell"];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"SwitchCell"] autorelease];
}
cell.textLabel.text = @"Sounds";
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectZero];
cell.accessoryView = switchView;
[switchView setOn:[[Settings sharedInstance] playSounds] animated:NO]; // initialize value from Settings
[switchView addTarget:self action:@selector(switchChanged:) forControlEvents:UIControlEventValueChanged];
[switchView release];
}
else if ([aSection integerValue] == PERSON) {
cell = [tableView dequeueReusableCellWithIdentifier:@"PersonCell"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"PersonCell"] autorelease];
}
Person *p = [_personArray objectAtIndex:row];
cell.textLabel.text = [NSString stringWithFormat:@"%@ %@", p.firstName, p.lastName];
NSLog(@"cL: %@", NSStringFromCGRect(cell.textLabel.frame));
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
return cell;
}
我的PERSON部分爲用戶提供了更改人員的功能。在didSelectRowAtIndexPath方法的代碼是
else {
Person *p = [_personArray objectAtIndex:row];
NSUInteger oldRow = [_lastIndexPath row];
if (oldRow != row) {
dmgr.currentPerson = p;
// Put checkmark on newly selected cell
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryCheckmark;
// Remove checkmark on old cell
UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:_lastIndexPath];
oldCell.accessoryType = UITableViewCellAccessoryNone;
[_settingsTableView deselectRowAtIndexPath:_lastIndexPath animated:YES];
self.LastIndexPath = indexPath;
// Update the cell
NSIndexPath *path = [NSIndexPath indexPathForRow:0 PERSON];
UITableViewCell *theCell = [_settingsTableView path];
theCell.textLabel.text = [NSString stringWithFormat:@"%@ %@", p.firstName, p.lastName];
[theCell setNeedsDisplay];
NSLog(@"ceLL: %@", NSStringFromCGRect(theCell.textLabel.frame));
}
}
會發生什麼事,直到我點擊標籤上的標籤被截斷。 (例如John D ...而不是John Doe)。爲什麼標籤不能更新?
我試着看着框架,我不確定這是否與它有關。我的輸出是:
cL: {{0, 0}, {0, 0}}
ceLL: {{10, 11}, {76, 21}}
minimumFontSize在iOS 6中已棄用 – whyoz