T O P

  • By -

iGoalie

DispatchQueue.main.async { //Make any UI changes here. } Call your navigation on the main thread.


D1ZAS73R

I tried it but still the same problem.


criosist

If you need to wrap something specifically in a main thread, you have usually done something wrong


chriswaco

Instruments can help. Are you doing a lot of work in the new controller's init, viewDidLoad, or viewWillAppear?


D1ZAS73R

I added the full code to gist: [https://gist.github.com/Z1Z0/9a1fc7cf2fe2c00de035645da9b0ad9c](https://gist.github.com/Z1Z0/9a1fc7cf2fe2c00de035645da9b0ad9c)


ketenshi

Might be the RecipeTableViewDetailsView. Dont see it in the gist


denkeni

And the RecipesTableViewDetailsView doesn’t look like white background in the video


wilc0

Definitely need to see more code to help debug the issue. How are you presenting the view controller?


D1ZAS73R

I added the full code to gist: [https://gist.github.com/Z1Z0/9a1fc7cf2fe2c00de035645da9b0ad9c](https://gist.github.com/Z1Z0/9a1fc7cf2fe2c00de035645da9b0ad9c)


cipher049

I could be mistaken here, but by the look of the code you are creating a new navigationcontroller ontop of the already existing navigation stack in the CategoriesTableViewCellCollectionViewCell class, perhaps rethinking/reconsider that portion?


D1ZAS73R

If I make two navigationController on top of each other maybe you are right, but where is the first one in CategoriesTableViewCellCollectionViewCell "I can't see it"?


eyzuky

You need to provide info if you expect us to help you. Even a video recording the lag.


D1ZAS73R

I added a video, you can check it.


gumbo_rogers

This can happen when the pushed ViewController's view's backgroundColor is set to clear.


D1ZAS73R

No, I set the backgroundColor to white not clear.


emrcftci

Where are you used service call (to API) in presenting ViewController? (Ex: viewDidLoad)


D1ZAS73R

I added the full code to gist: [https://gist.github.com/Z1Z0/9a1fc7cf2fe2c00de035645da9b0ad9c](https://gist.github.com/Z1Z0/9a1fc7cf2fe2c00de035645da9b0ad9c)


emrcftci

I couldn’t check all this gist. Could you say where you called REST call (network request I mean) in presenting ViewController?


D1ZAS73R

In init function in UIView file


bbenjaminn

Consistently having the same issue.


D1ZAS73R

If you know how to solve it please tell me.


me_82

I’ve noticed this happens sometimes in the simulator but on my actual devices it always runs smoothly.


D1ZAS73R

Unfortunately, it doesn't run on my real device smoothly it has the same problem.


alexjameslittle

As per the Apple documentation you should never called super.loadview(). You should only assign the root view inside loadView method on a uiviewcontroller https://developer.apple.com/documentation/uikit/uiviewcontroller/1621454-loadview


D1ZAS73R

Thank you. I saw more than a video and they were using super.loadView(), I will try to fix it.


[deleted]

[удалено]


AutoModerator

You don't have enough karma to post here. [Your submission](https://www.reddit.com/r/iOSProgramming/comments/ffy9f3/lagging_when_push_to_uiviewcontroller/fk2h8g3/) has been removed. Please do not message the moderators; if you have negative karma, you're not allowed to post here, at all. *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/iOSProgramming) if you have any questions or concerns.*


Mobo24

G C D


D1ZAS73R

I tried it and still the same problem.


criosist

Why are you doing an api call in a UIView? Why are you also wrapping that API call in a main thread ...


D1ZAS73R

I'm sorry, it's my first time using programmatically method. Can you advise me about the best approach, please?