2013-09-30 137 views
0

我有一個UIViewController與內UINavigationViewController層次結構。當我對另一個視圖控制器進行push-and-pop或者present-and-dismiss時,地圖視圖會刷新切片。我想在現在和結束之後避免讓人耳目一新。我曾嘗試:如何避免MKMapView刷新?

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
    // ... 
    MyModalViewController * vc = segue.destinationViewController; 
    vc.view.backgroundColor = [UIColor clearColor]; 
    self.modalPresentationStyle = UIModalPresentationCurrentContext; 
    // ... 
} 

但地圖視圖劇照駁回後刷新磚...

回答

0

這是爲了避免一個視圖控制器上清爽的地圖有道:

self.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext; 
2

而不是重新創建每次你做SEGUE時候你MyModalViewController,把視圖控制器爲延遲加載實例變量和用它作爲seque。這樣它只設置一次,地圖不會刷新。每當vc出現時,你仍然需要做任何設置和拆卸。