SettingsViewController.h我正在尝试从放置在子视图 ( )内的按钮注销。所以我从 登录LogInViewController.h,然后转到我HomeViewController.h的 ,其中有一个条形按钮项 Settings,它执行以下代码:
-(IBAction)settingsButton:(id)sender{
    SettingsViewController* settings = [[SettingsViewController alloc]init];
    settings.view.tag = 7; //This is to remove the settings from view in SettingsViewController.h
    [self.tabBarController.view addSubview:settings.view];
}
我想将视图添加SettingsViewController.h为子视图,以便我可以拥有透明背景,并且HomeViewController.h视图在视图后面仍然可见SettingsViewController.h。
现在SettingsViewController.h,我遇到了实际问题。我有一个注销按钮,并LoginViewController.h在单击该按钮后尝试显示视图。所以这里是代码SettingsViewController.h:
-(IBAction)logoutButton:(id)sender{
    //I cleared all user preferences here
    //ex. [user loggedOut];
    LoginViewController *backToLoginScreen = [[LoginViewController alloc]init];
    [self presentViewController:backToLoginScreen animated:NO completion:nil];
    [[self.view viewWithTag:7] removeFromSuperview]; //This is supposed to remove the Settings view from the view, but if I try to log in again, the setting view will come up
}
所以我猜,一旦我调用了presentViewController,它不会删除任何视图,但我不知道如何删除 Settings 视图。请帮忙?谢谢!