我有一个观点,即增加了一个图在上面以这种方式:的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