2012-10-23 54 views
-2
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath: 
(NSIndexPath *)indexPath 
{ 
    UITableViewCell *cellName=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell1"]; 
    NSDictionary *contentdict=[innerarray objectAtIndex:indexPath.row]; 
    static NSString *[email protected]"cell"; 
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellidentify]; 

} 

這是我的代碼,每一件事情是工作,但崩潰出現自我 有我需要寫R改變任何事????? 我正在使用Xcode 4.5> UITableView的崩潰(終止叫做拋出異常(LLDB))

+1

是,該方法認真的模樣? – JustSid

+0

被顯示在tableview中的數據? – IronManGill

+0

你可以把整個崩潰日誌?你在使用ARC嗎? –

回答

0

我認爲這是崩潰,因爲您沒有從cellForRowAtIndexPath方法返回任何單元格。變化cellForRowAtIndexPath,如:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; 
{ 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 


    if (cell == nil) 
    { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"] autorelease]; 
    } 

    //do something with the cell 

    return cell; 
} 
1

試試這個......可能是它幫助....

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath: 
(NSIndexPath *)indexPath 
{ 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 

    if (cell == nil) 
    { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"] autorelease]; 
    } 

    NSDictionary *contentdict = [[NSDictionary alloc]init]; 
    if([innerarray count]>0) 
    { 
     contentdict =[innerarray objectAtIndex:indexPath.row]; 
    } 

// Write your other cell stuff.... 

    return cell; 
} 
相關問題