objective-c - ios页面跳转有点卡顿
PHP中文网
PHP中文网 2017-04-18 09:15:45
0
12
804

其中一个ViewController执行以下语句

UIViewController *vc = [[UIViewController alloc] init];
[self.navigationController pushViewController:vc animated:false];

将要被push的ViewController的viewDidLoad方法中,我init了一个textview和一个button,并且addSubview了,然后我在viewWillAppear方法中设置了他们的一点属性,用Masonry做了布局。
然后在第一次push的时候会产生卡顿,请问有什么方法避免?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(12)
刘奇

First of all, you need to clear where the lag occurs. Use Time Profiler to see it
or you can post the code

Peter_Zhu

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

PHPzhong

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

Ty80

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template