UITableView,无法设置textlabel.text和text.label.font

时间:2014-06-19 21:10:27

标签: ios uitableview

在viewDidLoad中我添加

[super viewDidLoad];
if ([[API sharedInstance] isAuthorized]) {
    [self userInfo];
}

然后

-(void)userInfo{
API* apiUser = [API sharedInstance];
//load the caption of the selected photo

[apiUser commandWithParams: [NSMutableDictionary dictionaryWithObjectsAndKeys:@"get_user_data", @"command", nil] onCompletion:^(NSDictionary *json) {
    //got stream
    NSArray* list = [json objectForKey:@"result"];
    NSDictionary* userInfo = [list objectAtIndex:0];
    name = [NSString stringWithFormat:@"%@ %@",[userInfo objectForKey:@"name"], [userInfo objectForKey:@"surname"]];
}];
}

最后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;
}

有谁知道如何解决问题?

0 个答案:

没有答案