2013-12-17 50 views
-1

當我輸入Xcode的規劃問題的tableview - 「控制到達非void函數結束」

-(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 [email protected]"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

+2

順便說一句,你拼寫錯了所有的方法名稱,所以他們都不會被調用。 – jlehr

回答

0

它說:控制到達,非void函數

你宣佈你的方法與UITableViewCell*返回類型的結束,但方法不會返回一個值。您需要添加return語句,該語句返回指向表格單元格的指針。

4

你的函數一樣,年底前只需添加「恢復單元」:

- (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的是區分大小寫的!

+0

是的,我做到了,但是,我仍然得到警告 – user3112096

+0

什麼樣的警告?如果您不告訴我們這些警告的細節,我們無法幫助您! –

+0

它是一個控制達到非函數的結尾void – user3112096

相關問題