2013-12-19 60 views
-3

我使用下面我tableViewController類代碼的末尾: 與以下錯誤:錯誤:控制到達非void函數

錯誤:控制到達非void函數結束

//customize the appearance of the table view cell 

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

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


    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) 
    { 
     cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
    } 

    //configure the cell 

    cell.textLabel.text = [optionList objectAtIndex:indexPath.row]; 


} 
+1

'return cell;'... – Wain

+0

你甚至試過用google搜索錯誤信息嗎? – 2013-12-19 19:21:29

+0

是的我有我得到一堆鏈接到這個網站,每當我嘗試使用溶劑我發現它從來沒有工作。 – codychris

回答

1

只需將您的方法替換爲:

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

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


    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) 
    { 
     cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
    } 

    //configure the cell 

    cell.textLabel.text = [optionList objectAtIndex:indexPath.row]; 

    //This code you did not added earlier... 
    return cell; 

} 

我剛剛將return cell;添加到您的代碼中。

相關問題