Ketan Patel
Ketan Patel

Reputation: 560

Load while push to another viewController

When i push to my detail viewcontroller after clicking the collectionview cell it take time to load detailview Controller. MainViewController.m

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{

    DetailViewController *objDetailViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"];
    objDetailViewController.objProduct = [arrList objectAtIndex:indexPath.row];
    [self.navigationController pushViewController:objDetailViewController animated:YES];
}

DetailViewConteroller.m

- (void)viewDidLoad {

    [super viewDidLoad];
    [self setInitialValues];
    [self productDetailAPI];//WS CALL

}

Upvotes: 2

Views: 72

Answers (2)

Ofcourse
Ofcourse

Reputation: 647

if "productDetilAPI" is a web request function, it will stop the UI, as mentioned in the above answer, so what you should do is

[self performSelectorInBackground:@selector(productDetailAPI)
                           withObject:nil];

Hope this help

Upvotes: 1

Rami
Rami

Reputation: 179

Is the API call running on the main thread? You should make network calls on the background thread to not block the UI thread.

Upvotes: 3

Related Questions