Core Location and UITableView performance issues in iOS 8

110 views Asked by At

I have a view controller that contains two views: a map view using the Google Maps API and a UITableView.

The view controller fetches a list of location objects from Google Maps within a certain radius of a particular location and plots them on the map view as markers and the UITableView as UITableViewCells.

User can then tap on a button to transition between these two views.

This works very smoothly in iOS 7. However in iOS 8, if I request user's location permission by setting up the request permission key-value pair (NSLocationWhenInUseUsageDescription in my case) in my .plist, there is a significant lag when I transition from the map view to the UITableView, and there is also a lag when attempting to scroll the UITableView.

As soon as I remove the NSLocationWhenInUseUsageDescription key in the .plist, it works fine.

I've tried to remove all cell configuration, but the lag exists even loading a UITableView with no cells.

Here is my tableView:cellForRowAtIndexPath method after I removed all cell configurations:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{   
        MyTableCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyTableCell" forIndexPath:indexPath];

        if (!cell) {
            cell = [[StoreCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MyTableCell"];
        }

        return cell;
}

Has anyone experienced similar issues? I wonder if this is a bug in iOS 8.

Sorry about the long post, but just wanted to be as thorough as possible.

Thanks!!

1

There are 1 answers

0
Harry Wang On BEST ANSWER

Figured out the issue. Turned out that I never stopped the locationManager from updating the current user location so the didUpdateLocations delegate method was being called continuously and consuming resources. Once I sent the stopUpdatingLocation method to the location manager it fixed the problem