gpt4 book ai didi

ios - 默认实现中缺少 UITableViewCell detailTextLabel

转载 作者:行者123 更新时间:2023-11-29 02:47:43 26 4
gpt4 key购买 nike

对大家来说这似乎是一个重复的问题,但我已阅读所有主题,但尚未找到答案,因此我决定发布一个新问题。

我正在使用 UITableViewCellStyleSubtitle 的默认实现,但 detailTextLabel 不会出现,除非我每次都创建一个新单元格。

这是代码

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.

[tblvUsersList registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return (self.registeredUser && self.registeredUser.count > 0)?self.registeredUser.count:0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
if (self.registeredUser.count > indexPath.row) {

AppDelegate* appDelegate = [[UIApplication sharedApplication] delegate];

if (self.currentViewType == ViewTypeUsers) {
UserModal* user = [self.registeredUser objectAtIndex:indexPath.row];
cell.textLabel.text = user.userName;
cell.detailTextLabel.text = user.email;
// NSLog(@"Detail Text is %@",cell.detailTextLabel.text);
//Console Prints Null here
}

return cell;
}

最佳答案

尝试换行

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

关于ios - 默认实现中缺少 UITableViewCell detailTextLabel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24904355/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com