其中一个ViewController执行以下语句
UIViewController *vc = [[UIViewController alloc] init];
[self.navigationController pushViewController:vc animated:false];
将要被push的ViewController的viewDidLoad方法中,我init了一个textview和一个button,并且addSubview了,然后我在viewWillAppear方法中设置了他们的一点属性,用Masonry做了布局。
然后在第一次push的时候会产生卡顿,请问有什么方法避免?
怪我咯2017-04-18 09:17:45
First of all, you need to clear where the lag occurs. Use Time Profiler to see it
or you can post the code
迷茫2017-04-18 09:17:45
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
大家讲道理2017-04-18 09:17:45
The view backgroundcolor of the skipped viewcontroller cannot be clearcolor
阿神2017-04-18 09:17:45
How to initialize an instance of a class? Isn't the name of the class you want to jump to called UIViewController.h?
大家讲道理2017-04-18 09:17:45
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?
高洛峰2017-04-18 09:17:45
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
PHP中文网2017-04-18 09:17:45
It is best to set the background color of the push controller, otherwise it will cause rendering lag
大家讲道理2017-04-18 09:17:45
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.