我試圖讓細胞的細節文本居中。detailTextLabel textalignment
我已閱讀所有類型的帖子,但他們似乎都在談論老版本的IOS。我認爲我嘗試了所有帖子的組合,但沒有運氣讓它工作。
[[cell detailTextLabel] setTextAlignment:UITextAlignmentCenter];
我想這從willDisplayCell並在下面的代碼,無論是作品。注意兩種方法,我嘗試了這兩種方法。
有誰知道這是否工作,或者我應該創建自己的中心功能(方法)?
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:18.0];
cell.detailTextLabel.font = [UIFont systemFontOfSize:16];
NSMutableDictionary *curRow = [myData objectAtIndex:indexPath.row];
cell.textLabel.text = [curRow objectForKey:@"Description"];
cell.detailTextLabel.text = [curRow objectForKey:@"Stats"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.detailTextLabel.textAlignment = UITextAlignmentCenter;
非常感謝您的詳細解答! –
我可以做第三個子視圖嗎? –
當你自定義單元格時,你不需要擔心樣式。你想做什麼,就可以做什麼。 – iPrabu