其中一个ViewController执行以下语句
UIViewController *vc = [[UIViewController alloc] init];
[self.navigationController pushViewController:vc animated:false];
将要被push的ViewController的viewDidLoad方法中,我init了一个textview和一个button,并且addSubview了,然后我在viewWillAppear方法中设置了他们的一点属性,用Masonry做了布局。
然后在第一次push的时候会产生卡顿,请问有什么方法避免?
First of all, you need to clear where the lag occurs. Use Time Profiler to see it
or you can post the code
Have you set the background color in the controller you jump to?
There are too many things that need to be loaded. Pay attention to your code logic. There are too many reasons for lags. You need to find out the problems and make targeted optimizations
You can set a white background for the jumped controller view
The view backgroundcolor of the skipped viewcontroller cannot be clearcolor
How to initialize an instance of a class? Isn't the name of the class you want to jump to called UIViewController.h?
It may be a problem with the background color of the next page. We have encountered it before. Is it possible to set the transparency?
Writing something like this, will it get stuck? It may be a backgroundColor problem, it’s best to fill in the code and take a look
It is best to set the background color of the push controller, otherwise it will cause rendering lag
Do it in view did appear. Both viewwillappear and transition animation are in the same runloop iteration, and autolayout itself is very performance-intensive. Putting both layout and animation in the same runloop iteration will increase the burden on that iteration.