我對iPhone應用程序開發非常陌生。
我正在開發一個使用Objective-C++和std CPP的iPhone模擬器的示例應用程序。從另一個視圖控制器中刪除視圖控制器
我在我的應用程序中有兩個視圖,來自CPP代碼的一些事件中,我使用第一個視圖控制器的以下代碼顯示第二個視圖。
// Defined in .h file
secondViewScreenController *mSecondViewScreen;
// .mm file Code gets called based on event from CPP (common interface function between Objective-C++ and CPP code)
mSecondViewScreen = [[secondViewScreenController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:mSecondViewScreen animated:YES];
我能看到第二視圖上的屏幕來了,但問題是,我無法停止/從第一視圖控制器刪除第二個視圖控制器。
如何從第一個視圖控制器使用第二個視圖控制器的指針或使用任何其他方法刪除第二個視圖控制器。
要刪除第二個視圖,我有第二個視圖控制器文件中的以下代碼,它被第二個視圖的按鈕單擊事件調用。
// In .mm of second view controller.
- (IBAction)onEndBtnClicked:(UIButton *)sender
{
[self dismissModalViewControllerAnimated:NO];
[self.navigationController popViewControllerAnimated:YES];
}
上面的代碼工作完美,當我在秒視圖的結束按鈕,單擊它從屏幕移開並navigets先來看第二個視圖控制器,我怎麼能使用相同的代碼來從第一視圖中刪除第二視圖控制器。
我綁定使用NSNotificationCenter
將事件從第一個視圖發送到第二個視圖來調用功能onEndBtnClicked
但它不起作用。
這樣做的正確方法是什麼?
OSX版本:10.5.8和Xcode的版本:3.1.3
顯示使用NSNotificationCenter時的部分。 –