2014-02-11 30 views
0

在Xcode中4我能去的地方我用了ModalViewController使用下面的代碼根視圖:LS有沒有辦法去根視圖使用ModalViewController:

[mHomeController dismissModalViewControllerAnimated: true]; 
[mHomeController.view addSubview:mHomeController->adView]; 

mHomeController是一個全球性的指向第一個視圖控制器。

當我升級到5的Xcode我得到一個錯誤行:

[mHomeController dismissModalViewControllerAnimated:真]; [mHomeController.view addSubview:mHomeController-> adView];

話說方法AdView中不存在,

現在,沒有我的項目將建成。有沒有辦法來解決這個問題?

+0

是否行得通? – Linuxios

回答

0

嘗試

[self dismissViewControllerAnimated:YES completion:^{ 

// try this and the additional code below 
[[NSNotificationCenter defaultCenter] postNotificationName:@"POPTOROOTVIEW" object:nil]; 

//or just this line as it may be that you're popToRoot is called before the modal view is animated off 

    [self.navigationController popToRootViewControllerAnimated:YES]; 
    }]; 

然後在另一個視圖控制器有這個

如果你改變'mHomeController-> adView`到`mHomeController.adView`
- (void)viewDidLoad 
{ 
.... 
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(popToRootViewPlease) name:@"POPTOROOTVIEW" object:nil]; 
.... 
} 

- (void)popToRootViewPlease 
{ 
    [self.navigationController popToRootViewControllerAnimated:YES]; 
} 

- (void) dealloc 
{ 
    [[NSNotificationCenter defaultCenter]removeObserver:self]; 

} 
+0

沒有沒有wprk只是去預覽謝謝你的想法 –

+0

我已經更新了我的答案嘗試。 – AppHandwerker

相關問題