【问题标题】:xcode programming problem tableview - "control reaches end of non-void function" [duplicate]xcode编程问题tableview - “控制到达非无效函数的结尾” [重复]
【发布时间】:2013-12-17 16:55:22
【问题描述】:

当我输入时

-(NSInteger) numberOfSectionsInTabelVieuw:(UITableView *)tabelVieuw{
    return 1;
}

-(NSInteger)tabelVieuw:(UITableView *)tabelvieuw numberOfRowsInSection:(NSInteger)section{

    return [soundTitles count];
}

-(UITableViewCell *)tabelview:(UITableView *)tabelvieuw cellForRowATIndexPath:(NSIndexPath *)Indexpath
{
    static NSString *CellIndentiefier =@"cell";

    UITableViewCell *cell =[tabelVieuw dequeueReusableCellWithIdentifier:CellIndentiefier];
    if(cell ==Nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIndentiefier];
        if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
            cell.accessoryType= UITableViewCellAccessoryDisclosureIndicator;
        }

    }
    //CONFUGURE THE CELL
    cell.textLabel.text =[soundTitles objectAtIndex:Indexpath.row];
    ;
}

我总是在最后一个} 收到警告。 它说:control reaches, end of non-void function

【问题讨论】:

  • 顺便说一句,你拼错了所有的方法名称,所以它们都不会被调用。

标签: objective-c xcode clang


【解决方案1】:

只需在函数结束前添加“返回单元格”即可:

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

    UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if(!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
            cell.accessoryType= UITableViewCellAccessoryDisclosureIndicator;
        }

    }
    //CONFIGURE THE CELL
    cell.textLabel.text =[soundTitles objectAtIndex:indexPath.row];
    return cell;
}

编辑:更正拼写 - 注意 Objective-C 区分大小写!

【讨论】:

  • 是的,我做到了,但我仍然收到警告
  • 什么样的警告?如果您不向我们提供这些警告的详细信息,我们将无法帮助您!
  • 这是一个控件到达非函数 void 的结尾
  • 但现在它可以正常工作了
【解决方案2】:

它说:控制到达,非空函数结束

您已经用UITableViewCell* 的返回类型声明了您的方法,但该方法从不返回值。您需要添加一个return 语句,该语句返回一个指向表格单元格的指针。

【讨论】:

    猜你喜欢
    • 2016-05-07
    • 1970-01-01
    • 2017-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多