UITableViewController警告-帮助!

问题描述

| 所以,我在下面发布我的代码
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath     // I get a warning here Incomplete method implementation //
{
    static Nsstring *CellIdentifier = @\"Cell\";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    // Configure the cell...
    NSLog (@\"dobby4\");
    NSInteger row = [indexPath row];
    cell.text = [dogArray objectAtIndex:row];

    //I get a warning for the line above-- \'text\' is deprecated //
    return cell;
}
所以, 1.我收到警告-该函数方法实现不完整。 2.我又收到一条警告“文本”已过时” 3.我尝试调试并尝试打印“ dobby4”行,但未打印。 我将不胜感激。     

解决方法

我怀疑是否与此功能有关。大概是以前的方法。如果您也将其放在代码清单中,那将是很好的。 您不应该使用
text
属性设置文本(不建议使用,正如警告所述)。使用
textLabel
,它是
cell
的子视图。所以那行是
cell.textLabel.text = [dogArray objectAtIndex:row];
。 由于未打印
Dobby4
,因此
numberOfSectionsInTableView:
tableView:numberOfRowsInSection:
返回0。如果不是,则表明您未正确连接数据源。     ,1)编译器可能会抱怨,因为方法实现可能不会出现在头文件中,反之亦然? 2)自iOS 3.0以来,确实不推荐使用UITableViewCell的.text属性,因此您肯定无法使用更高版本的iOS,因此您将无法使用它。 3)也许与1)有关。 希望这对您有所帮助,请及时发布!