1. 程式人生 > >ios跳轉頁面時出現卡頓現象

ios跳轉頁面時出現卡頓現象

首先看程式碼:

                RealtimeViewController *realvc=[[RealtimeViewController alloc]init];
                [self.navigationController pushViewController:realvc animated:YES];

其中RealtimeViewController是一個繼承自uiviewcontroller的控制器,只是建立,然後什麼程式碼都沒有寫。

#import "RealtimeViewController.h"

@interface RealtimeViewController
()
@end @implementation RealtimeViewController - (void)viewDidLoad { [super viewDidLoad]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } @end

然後我們有時候發現跳轉時,頁面出現卡頓現象。可是我都還沒有寫任何程式碼,這是什麼鬼,最後研究半天終於發現了問題。
解決辦法:在viewDidLoad裡面給view設定背景色就可以了。

 self.view.backgroundColor
=[UIColor redColor]; //當然這個顏色是根據需要設定的。