2012-08-17 8 views
0

UITableViewController сбой при ошибке с ошибкой. Это мой код:Ошибка при прокрутке стола viewcontroller

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 
    NSString *cellText ; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) 
    { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ; 
    } 
    if (indexPath.row == 0) 
    { 
     cellText = @"Mail1"; 
    } 
    else if (indexPath.row == 1) 
    { 
     cellText = @"Mail2"; 
    } 
    else if (indexPath.row == 2) 
    { 
     cellText = @"Mail3"; 
    } 
    else if(indexPath.row == 3) 
    { 
     cellText = @"Mail4"; 
    } 
    else 
    { 
     cellText = @"Mail5"; 
    } 
    cell.textLabel.text = cellText; 
    return cell; 
} 

это Xcode сообщение журнала дал

XXXXProject [1366: F803] * - [XXXXViewController Tableview: cellForRowAtIndexPath]: сообщение, отправленное на освобождаться экземпляра 0x6a793f0

+3

Можете ли вы разместить журнал аварий? – janusbalatbat

+2

О том, какая строка приложения падает? – Vladimir

+0

XXXXProject [1366: f803] *** - [XXXXViewController tableView: cellForRowAtIndexPath:]: сообщение отправлено на освобожденный экземпляр 0x6a793f0 это сообщение с сообщением xcode дано @janusfidel – ohmprakash

ответ

0

Я думаю, что вам не нужно инициализировать ячейку. Возможно, раскадровка инициализирует ячейку.

ss

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

    // Configure the cell... 
    NSString *cellText; 
    if (indexPath.row == 0) 
    { 
     cellText = @"Mail1"; 
    } 
    else if (indexPath.row == 1) 
    { 
     cellText = @"Mail2"; 
    } 
    else if (indexPath.row == 2) 
    { 
     cellText = @"Mail3"; 
    } 
    else if(indexPath.row == 3) 
    { 
     cellText = @"Mail4"; 
    } 
    else 
    { 
     cellText = @"Mail5"; 
    } 
    cell.textLabel.text = cellText; 
    return cell; 
} 

Вы можете скачать этот пример проекта из GitHub, и просто запустить его.

https://github.com/weed/p120817_TableTest

+0

Это ошибка, я получил XXXXProject [1906: f803] *** Ошибка утверждения в - [UITableView _createPreparedCellForGlobalRow: withIndexPath:], /SourceCache/UIKit_Sim/UIKit-1914.84/UITableView.m:6061 2012-08-17 15 : 23: 02.965 NewProject [1906: f803] *** Завершение приложения из-за неперехваченного исключения «NSInternalInconsistencyException», причина: «UITableView dataSource должен вернуть ячейку от – ohmprakash

+0

, что URL-адрес вообще не работает. – ohmprakash

+0

Извините! http://github.com/weed/p120817_TableTest – weed

0

Точно такой же вопрос был только что отправил на StackOverflow за несколько часов до этого. (Там нет табличного представления, называемого его делегатом, но UIButton его действие). Вероятно, проблема заключается в том, что у вас нет четкой ссылки на ваш контроллер табличного представления, поэтому он освобождается сразу после создания. See my answer to the previous question.

+0

PLZ объяснить детали @ H2CO3 – ohmprakash

Смежные вопросы