2015-02-11 48 views
0

在我的iPhone应用程序,我有这样的委托方法:手动执行表重装

- (void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region 
{ 
    //lots of logic here, but in the end I do a 
    [self.tableView reloadData]; 

} 

出于测试目的,我想手动加载表虚拟数据。为此,我有一个UIButton,触发

-(IBAction)reloadTable:(id)sender{ 
    [self.tableView reloadData]; 
} 

不知何故,没有任何反应,当我按下按钮时。我希望

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

被调用,但它不是。

我推理的洞在哪里?

+2

是tableview数据源/委托集?你的数据源中是否有新的数据?您的reloadTable IBAction只是重新加载表,它不会将更多数据添加到数据源? – CW0007007 2015-02-11 14:49:14

+0

是,设置了源代码和委托。但可能没有新的数据。如果我有更多信息,我会回到这里。我认为reloaddata会经历整个tableview委托方法,不管(新)数据是否存在( – Sjakelien 2015-02-11 15:36:45

+0

),但是如果没有新数据,你期望看到 – CW0007007 2015-02-12 07:19:27

回答

0

在您的 - (IBAction)reloadTable中放置一个中断点,运行该应用程序并点击按钮。如果代码不停在断点处,则需要将该按钮的“touchUpInside”事件连接到 - (IBAction)。

如果它停在断点处,请确保tableView本身不是零,并且tableView的dataSource指向您的viewController。

IBAction问题是最可能的原因。

+0

我做了断点。我想@ CW0007007是正确的,因为没有新的数据。无论如何,我认为它会循环该代码。 – Sjakelien 2015-02-11 15:35:13