Ios UITableView,无法设置textlabel.text和text.label.font
在viewDidLoad中,我添加了Ios UITableView,无法设置textlabel.text和text.label.font,ios,uitableview,Ios,Uitableview,在viewDidLoad中,我添加了 [super viewDidLoad]; if ([[API sharedInstance] isAuthorized]) { [self userInfo]; } 然后 最后,cell.textLabel.text和cell.textLabel.font没有得到任何结果,文本与故事板中的文本相同,默认为字体 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtI
[super viewDidLoad];
if ([[API sharedInstance] isAuthorized]) {
[self userInfo];
}
然后
最后,cell.textLabel.text和cell.textLabel.font没有得到任何结果,文本与故事板中的文本相同,默认为字体
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [self.menuItems objectAtIndex:indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (indexPath.row == 0) {
if (name != nil) {
cell.textLabel.text = name;
}
cell.contentView.backgroundColor = [UIColor colorWithRed:0.8 green:0.0 blue:0.03 alpha:1.0];
UIFont *myfontTop = [ UIFont fontWithName:@"myFont" size:IS_PAD?17:11];
cell.detailTextLabel.font = myfontTop;
cell.textLabel.textColor = [UIColor blueColor];
} else {
UIFont *myfont = [ UIFont fontWithName:@"myFont" size:IS_PAD?17:11];
cell.contentView.backgroundColor = [UIColor grayColor];
cell.textLabel.font = myfont;
}
return cell;
}
有人知道如何解决这个问题吗?[self.tableView reloadData]?我需要在哪里重新加载数据?在您获得了应该显示在表视图上的新数据之后,我找到了可以放置重新加载的位置,但现在它根本不是故事板样式,我需要通过代码对其进行更改?不是故事板?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [self.menuItems objectAtIndex:indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (indexPath.row == 0) {
if (name != nil) {
cell.textLabel.text = name;
}
cell.contentView.backgroundColor = [UIColor colorWithRed:0.8 green:0.0 blue:0.03 alpha:1.0];
UIFont *myfontTop = [ UIFont fontWithName:@"myFont" size:IS_PAD?17:11];
cell.detailTextLabel.font = myfontTop;
cell.textLabel.textColor = [UIColor blueColor];
} else {
UIFont *myfont = [ UIFont fontWithName:@"myFont" size:IS_PAD?17:11];
cell.contentView.backgroundColor = [UIColor grayColor];
cell.textLabel.font = myfont;
}
return cell;
}