3

This is how am pushing from ViewController A to ViewController B

UIStoryboard *mainStory = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ListingViewController *listView = [mainStory instantiateViewControllerWithIdentifier:@"listing"];

[self.navigationController pushViewController:listView animated:YES];

and i've tried this way as well using a segue in StoryBoard

[self performSegueWithIdentifier:@"Associate3" sender:sender];

Pushing to this ViewController for the first time freezes (around 4 sec) before start pushing, knowing that VC B contains UIScrollView Object in its XIB,

Did this happened to any of you, any one knows how to solve this delay?

EDIT:

i've already commented all webservice calling methods, nothing Changed! I think its an allocating delay, am using the storyboard initiating with identifier to push VC B, but when i used allocating method: VC *B = [[VC alloc] init], then pushing to this view works without delay, but the issue that i don't need to use the allocating method!!

samir
  • 77
  • 9

5 Answers5

2

Finally found the issue, it was the custom font that am using in the labels of the VC B, just set them back to System Font instead of Roboto solved my problem, i think the system takes time to find the Font with specific name. Hope this would be useful for others

samir
  • 77
  • 9
0

It seems you are performing some heavy operation on main thread in ViewWillAppear or ViewDidLoad of ViewController B

Comment whole code of both above mentioned methods and then run your application which verifies problem in app.

So if its verified then you must move your heavy operation from main thread to background thread.

Aamir
  • 16,329
  • 10
  • 59
  • 65
0

This might be because pushing is executed in different thread. Try pushing the viewController in main thread. i.e.,replace your push controller code with

dispatch_async(dispatch_get_main_queue(), ^{
    UIStoryboard *mainStory = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    ListingViewController *listView = [mainStory instantiateViewControllerWithIdentifier:@"listing"];

    [self.navigationController pushViewController:listView animated:YES];
});
Varun
  • 759
  • 6
  • 12
0

Try to change in ListingViewController class viewDidLoad method to call async

- (void)viewDidLoad {
  [super viewDidLoad];

  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
  //move your code here
  // if you need to do something on ui (reload table view e.t.c) - call async in main thread
    dispatch_async(dispatch_get_main_queue(), ^{
      //Your UI code
    });
  });
}
Sandr
  • 189
  • 9
  • the same result, nothing changed, its supposed to take an action directly after tapping on the button, but its freezing around 3 sec before taking this action !!!! – samir Jan 19 '16 at 07:08
  • Do you have something in viewWillDisappear ? – Sandr Jan 19 '16 at 07:11
  • It would be better if you show us your code, where you are calling web service. – Sandr Jan 19 '16 at 09:19
  • Dear, i've already commented all webservice calling methods, nothing Changed! I think its an allocating delay, am using the storyboard initiating with identifier to push VC B, but when i used allocating method: VC *B = [[VC alloc] init], then pushing to this view it works without delay, but the issue that i don't need to use the allocating method!! – samir Jan 19 '16 at 14:29
0

You can use 'Instruments-Time Profiler', a developer tool with Xcode. It can check the time expense. Then, I think you will find you problem.

Peike Luo
  • 1
  • 2