等待在iPhone SDK CLLocationManagerDelegate的didUpdateToLocation方法时的UITableView不填充

StackOverflow https://stackoverflow.com/questions/707766

我试图填充一个UITableView与单元的阵列。我通常做这从viewDidLoad方法,但这个时候,我想填充基于位置的阵列。下面是我的界面的第一行:

@interface RootViewController : UITableViewController 
<UITableViewDelegate, UITableViewDataSource, CLLocationManagerDelegate> {

在实现文件viewDidLoad方法是这样的:

- (void)viewDidLoad {

    // for location
    self.locationManager = [[CLLocationManager alloc] init];
    [locationManager startUpdatingLocation];
    locationManager.delegate = self;
    locationManager.distanceFilter = kCLDistanceFilterNone; 
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;


    [super viewDidLoad];
}

我填充细胞在didUpdateToLocation方法数组:

    self.title = @"Open Buildings";

NSMutableArray *buildingArray = [[NSMutableArray alloc] initWithObjects:building1, 

self.controllers = array;

当位置被发现视图更新的标题,但在阵列不填充。该阵列并当我有在viewdidupdate上面的代码之前填充。我不得不将它移动到didupdatelocation方法,因为该应用程序将不会有位置信息时认为载荷viewDidLoad方法。

有帮助吗?

解决方案

您表视图不知道你有新的数据。所以,一旦你有新的数据,你需要告诉你的表格视图重载:

[myTableView reloadData];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top