加载UITableView时出错

时间:2012-02-02 13:35:29

标签: objective-c xcode tableview

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.nameList.count;

}
-(UITableViewCell *)tableview:(UITableView *)tableview cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *CellIdentifier=@"Cell";

    UITableViewCell *cell=[tableview dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell==nil) {

        cell=[[UITableViewCell alloc]initWithFrame:CGRectZero reuseIdentifier:CellIdentifier];
        //cell = [[UITableViewCell alloc]
        //   initWithStyle:UITableViewCellStyleDefault
        // reuseIdentifier:CellIdentifier];

    }
    //Setup the cell
     NSString *cellValue=[ListofItems objectAtIndex:indexPath.row];
    cell.text=cellValue;
    cell.textLabel.text = [self.nameList              objectAtIndex: [indexPath row]];

    return cell;

}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
你好,伙计们, 我有这些代码,我不能在我的tableview中看到我的价值观。并且它说:'程序收到信号sigabrt' 你能帮我解决我的错误吗?

1 个答案:

答案 0 :(得分:0)

 return self.nameList.count; 

当调用tableview numberOfRowsInSection时,nameList.count的值是多少?尝试将其设置为固定值以进行测试。也许你没有正确设置名单。

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;

}