2012-01-31 84 views
0

有时候reloadData方法UITableView不能正常工作,即意味着当我像[tableView reloadData]那样写时,它有时会调用数据源方法,有时候不会。UITableview重新加载问题iOS

什么可能是问题是,任何人都可以请给我答案。

这里是我的代码:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations. 
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){  
    [self performSelector:@selector(changeSegmentControllerFrame) withObject:nil afterDelay:0.0001];   
    [m_kwikiTable reloadData];  
    return YES;  } 
    else   
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 
+0

发布您的代码将有助于了解您的问题和代码... – 2012-01-31 07:05:35

+1

请张贴一些代码... – 2012-01-31 07:05:56

+0

这里我的问题是当我导航到一个视图,回到第一个视图比我的tableview委托方法被调用,但数据源方法不叫 – user1179681 2012-01-31 07:44:34

回答

0

尝试把一个断点

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 

方法......因为如果这样返回零,那么它不会打扰执行下一个方法即

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
+0

尝试通过放置断点“numberofrowsInSection”方法调用,但 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath :(NSIndexPath *)indexPath没有调用,没有得到什么问题。 – user1179681 2012-01-31 07:28:08

+0

当numberofrowsInSection被调用时,返回的行数是否大于0? – Prathiba 2012-01-31 08:43:01

+0

“这里我的问题是当我导航到一个视图,并返回到第一个视图比我的tableview委托方法被调用,但数据源方法没有调用” - 所以,在viewWillAppear的第一个视图,设置委托和数据源的tableview ,如果它有效,那么你在某个地方取消了数据源。 – Prathiba 2012-01-31 08:48:14

0

请添加代码。任何方式检查这些东西在您的代码。

  1. ,则应该设置cell.accessoryView了,如果(细胞==无){} 2.In - (空)的tableView:(UITableView的*)的tableView didSelectRowAtIndexPath方法:(NSIndexPath *)indexPath可以使用的tableView和不使用tableViewDistance(可能是零?) 3.In - (void)viewDidLoad你应该先调用[super viewDidLoad];然后进行自定义。

通过这个链接,这将帮助你调试:在委托

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 

tableView reloadData not working: cellForRowAtIndexPath not called

0

看跌的NSLog返回行计数,以检查其是否重新调整0之前或任何其他值