67418

pushViewController Extremely slow

Question:

What could cause pushViewController to be extremely slow? (it takes 30+seconds for the new view to appear)

Basically, I'm doing something like this:

SecondViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"correctID"]; vc.something = something; [self.navigationController pushViewController:vc animated:YES]; CLS_LOG(@"Pushed Controller...");

and i'm logging at the beginning of viewdidload inside the second view controller. I'm not subclassing other methods.

Between Pushed Controller... and the next log from viewdidload there's a huge delay.

How would you debug this?

I already tried with the TimeProfiler but apparently it shows nothing.

Answer1:

Had similar problem before, try the following

dispatch_async(dispatch_get_main_queue(), ^{ // your navigation controller action goes here });

Answer2:

Dino's answer saved my life. He got my upvote. I'm just adding this for modern swift users.

DispatchQueue.main.async { self.navigationController?.pushViewController(vc, animated: true) }

Answer3:

Setting the background color e.g. vc.view.backgroundColor = .white solves the issue for me.

Recommend

  • Can I check a C++ iterator against null?
  • How to change location of ValidationMessages.properties in Bean Validation
  • MVC map to nullable bool in model
  • MultiDexApplication not recognized
  • Countdown in seconds only (form 00:20 to 0) using NSTimer
  • amcharts line to be changed with different color if it goes down to the other line(after intersectin
  • Scrapy and submitting a javascript form
  • Sonar runner (ubuntu) execution failed: com.mysql.jdbc.Driver
  • Linq-to-SQL to search only DATE portions of a date
  • How to send data from one controller to other in angularjs
  • Should be localization part of domain in DDD
  • GCD implementation on a UITableView
  • jquery: Disable/Enable button not working after reset
  • Access VBA lookup folder and create if does not exist DLOOKUP
  • Why use 4096 elements for a char array buffer?
  • Setup SignalR and Service Bus inside a Azure Service Fabric service
  • Plugin with id Android not found
  • Objects Sorting With date ,Time Problem in Array(Iphone Development)
  • Counting the Words in a String [closed]
  • NextJS auth with an external server
  • Find a directory using wildcard in Inno Setup
  • How to detect beginning of line, or: “The name 'getCharPositionInLine' does not exist in t
  • Advertising Identifier for devices lower than iOS 6.0
  • Python read xml with related child elements
  • Lodash cloneDeepWith to omit undefined
  • Pyinstaller GLIBC_2.15 not found
  • Is there a way to run c# forms application without showing a gui window (like a console application)
  • date changes on export kendoGrid
  • Greedy Algorithm in “C”
  • Passing HTTP Post from AWS API GW to Lambda
  • Extract table from Powerpoint
  • Creating Dictionaries from Lists inside of Dictionaries
  • Tkinter tkMessageBox disables Tkinter key bindings
  • Unity Resources.load() won't work with external dll
  • Building JavaFX 2.0 App on Mac, deploying on Windows
  • How to split wav file into two or more parts using c#
  • Why isn't stemDocument stemming?
  • How to handle div that is created dynamically in a table
  • WPF custom control and direct content support
  • How to check if object is null in Java?