我有一張桌子。當我點擊表格行時,我想推新視圖。我知道,在navigationController以及如何推動它,但我想用這樣的代碼:點擊表格行推新視圖
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic -- create and push a new view controller
TasksViewController *tasks = [[TasksViewController alloc]
initWithNibName:@"Tasks"
bundle:nil];
LoginAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.window addSubview:[tasks view]];
[self.view removeFromSuperview];
}
的TaskViewCOntroller一種觀點我想要把這樣的。當我嘗試執行此操作時,我有這樣一個異常:
*** Assertion failure in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:], /SourceCache/UIKit_Sim/UIKit-1448.89/UITableView.m:5678
2011-09-16 12:26:41.118 LeoAction[1149:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
*** Call stack at first throw:
(
0 CoreFoundation 0x00df55a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f49313 objc_exception_throw + 44
2 CoreFoundation 0x00dadef8 +[NSException raise:format:arguments:] + 136
3 Foundation 0x000e03bb -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x0035ac91 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 883
5 UIKit 0x003504cc -[UITableView(UITableView
我不知道如何處理此異常?
請粘貼您的cellForRowAtIndexPath函數的代碼。 – MathieuF
代碼從'TasksViewController' – Nekto
該函數的 - (的UITableViewCell *)的tableView:(UITableView的*)的tableView的cellForRowAtIndexPath:(NSIndexPath *)indexPath { \t靜態的NSString * CELLID = @ 「customCell」; CustomCell * cell =(CustomCell *)[tableView dequeueReusableCellWithIdentifier:cellID]; \t \t 如果(細胞==無) \t { \t \t的NSArray * nibObjects = [[一個NSBundle mainBundle] loadNibNamed:@ 「CustomCell」 所有者:無選項:無]; \t \t爲(在nibObjects ID currentObject) \t \t { \t \t \t如果([currentObject isKindOfClass:[CustomCell類]]) \t \t \t { \t \t \t \t細胞=(CustomCell *)currentObject; \t \t \t} \t \t} \t} \t cell.textLabel.numberOfLines = 0; \t [cell.textLabel sizeToFit]; \t return cell; } – Petko