我有一個觀點,即增加了一個圖在上面以這種方式:的cellForRowAtIndexPath不會被調用
- (void)showAreaEditView {
NSLog(@"SHOWING AREA EDITOR VIEW");
if (self.thisAreaEditorView == nil) {
// Create View
AreaEditorView *tmpViewController = [[AreaEditorView alloc] initWithNibName:@"AreaEditorView" bundle:nil];
self.thisAreaEditorView = tmpViewController;
[tmpViewController release];
// Hide the back button
self.thisAreaEditorView.navigationItem.hidesBackButton = YES;
}
self.thisAreaEditorView.myInspectionID = self.myInspectionID;
self.thisAreaEditorView.loggedIn = loggedIn;
self.thisAreaEditorView.loggedInGroup = loggedInGroup;
// Slide view up
[self.view addSubview:thisAreaEditorView.view];
CGRect endFrame = CGRectMake(self.view.frame.size.width/2 - thisAreaEditorView.view.frame.size.width/2,
self.view.frame.size.height/2 - thisAreaEditorView.view.frame.size.height/2,
thisAreaEditorView.view.frame.size.width,
thisAreaEditorView.view.frame.size.height);
CGRect startFrame = endFrame; // offscreen source
// new view starts off bottom of screen
startFrame.origin.y += self.view.frame.size.height;
self.thisAreaEditorView.view.frame = startFrame;
// start the slide up animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.6];
thisAreaEditorView.view.frame = endFrame; // slide in
[UIView commitAnimations];
}
我敢肯定,你可以忽略的滑動部分,我覺得addSubview是相關的。
然後在thisAreaEditor中,我使用表格和按鈕等來查看視圖。 UITableView委託/數據源將正常進入文件所有者。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@"numberOfRowsInSection returning %d", [tableData count]);
[tableData count];
}
這個函數返回numberOfRowsInSection 4
- (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] autorelease];
}
// Configure the cell...
NSString *thisText = [tableData objectAtIndex:indexPath.row];
cell.textLabel.text = thisText;
NSLog(@"looking at cell %d text:%@", indexPath.row, thisText);
return cell;
}
不過的cellForRowAtIndexPath不會被調用。
我在這裏不知所措,我不知道它如何看起來工作正常,但其中一個委託函數根本不會被調用。
我試過[bigTable reloadData]
等等,表只是永遠不會被填充,並沒有日誌從函數輸出。
在此先感謝。
哦,我的,你是對的。我錯過了'numberOfRowsInSection'中的'return'。不能相信它那麼簡單,謝謝! – Batnom
im在'numberOfRowsInSection'中使用switch語句來處理8個不同的部分。並忽略了不包括「return」這個詞。有些問題可能很難解決。 – lizzy81