Delay when using instantiateViewControllerWithIdentifier but not performSegueWithIdentifier?

前端 未结 3 1035
臣服心动
臣服心动 2020-12-07 04:51

The code below is used to push another view controller onto the navigation stack.

When using instantiateViewControllerWithIdentifier, the segue is notic

相关标签:
3条回答
  • 2020-12-07 05:31

    The problem was isolated to the presence of a UITextField in the destination view controller, that is, removing the UITextField removes the lag.

    Then it was further isolated to the presence of a custom font.

    In other words, using the system font on the UITextField, rather than a custom font, removes the lag. No explanation why, but it works.

    0 讨论(0)
  • 2020-12-07 05:34

    This issue could occur in many different scenarios. The best way determine what is causing your specific problem is by profiling with the instruments included in Xcode.

    1. Click and hold the Build button in your xcode window. You will see four options appear, select Profile.
    2. Once the build runs a window with instruments will pop up. Select, Time Profiling from the options.
    3. A new window will appear with various metrics in it. The top left corner will have a red record button. Click the red record button and this will launch the app on your phone.
    4. Proceed to the transition giving you problems. End the recording after the transition occurs by selecting the same button you started the recording with.
    5. Review the "Details" pane in the bottom left corner. You will see a column titled "Running time" that shows the time it took to execute every method in your code (both OS methods and user generated code)
    6. Determine if anything is out of place or occurs that is not intended. Possibly go back and execute the transition again to compare the difference between the two. Clicking the function in the list will take you directly to the code being executed. This can be very helpful.

    It is very likely that if a transition takes 3-5 seconds one particular function will be obvious when following these steps. Happy profiling!

    WWDC from last year has a great segment on this as well. Def worth checking out here: (open in Safari only) WWDC Profiling Talk

    0 讨论(0)
  • 2020-12-07 05:54

    After time profiling I realized it was the call to instantiateViewController which I couldn't find anything that could help me with that.

    Unfortunately, the only thing that worked was either using a separate storyboard for that view controller and instantiating it from there, or redoing the view controller programmatically.

    0 讨论(0)
提交回复
热议问题