2009-07-30 20 views
1

當用戶點擊設置按鈕時,我的應用程序會拉起一個uitableview屏幕。我無法弄清楚如何聯繫請求來解決這個問題。如何關閉UITableView?

如何從uitableview中解除該視圖?

設置視圖:

SettingsController *rootViewController = [[SettingsController alloc] 
    initWithStyle:UITableViewStyleGrouped]; 
UINavigationController *navigationController = [[UINavigationController alloc] 
    initWithRootViewController:rootViewController]; 
settingsView = navigationController.view; 
settingsView.frame = 
    CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); 
[self.view insertSubview:settingsView atIndex:0]; 

帶來視圖前:

- (IBAction)settingsPressed:(id)sender{ 
[self.view bringSubviewToFront:settingsView]; 
} 

配售鑑於回:

- (void)QuitSettings { 
[self.view sendSubviewToBack:settingsView]; 
} 

捕獲在SettingsController 「返回」 按鈕點擊:

- (void) action:(id) sender{ 
//[super.view sendSubviewToBack:holdingView]; 
// access error [self release]; 
// nothing [holdingView removeFromSuperview]; 
// access error [super QuitSettings]; 
} 

回答

6

我聽起來像你想使用模態視圖,而不是在特定索引處插入子視圖。

您應該使用

[self presentModalViewController:myTableViewController animated:YES]; 

其中自是將要進行調用,彈出表視圖的視圖控制器。

然後你可以某處附加表視圖控制器,將調用

[self.parentViewController dismissModalViewControllerAnimated:YES]; 

駁回表視圖控制器上的按鈕或動作。

+0

平滑。你處理了我的直接問題和未說明的問題(我如何擺脫我用來調用uitableview的黑客?)。 – BankStrong 2009-07-30 11:20:27

0

這不工作?

[settingsView removeFromSuperView] 
+0

我認爲它工作正常,但我可以從哪裏調用它? – BankStrong 2009-07-30 11:12:41