iOS - 关闭RootViewController

时间:2016-01-08 03:01:08

标签: ios objective-c webview

我有一个这样的代码来呈现一个包含公司网页URL的TOWebViewController。

TOWebViewController *webViewController = [[TOWebViewController alloc] initWithURL:url];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:webViewController];
[[[[UIApplication sharedApplication] delegate] window] setRootViewController:navigationController];

打开之后我如何回到上一个视图或关闭根视图控制器,因为我的导航栏只显示灰色条。

感谢

2 个答案:

答案 0 :(得分:0)

请改用[self presentViewController:imagePickerController animated:YES completion:nil];。不要使用root视图控制器!

答案 1 :(得分:0)

您需要创建自定义func postWebserviceWithURL(strUrl: String, param: NSDictionary?, completionHandler: (NSDictionary?, NSError?) -> ()) -> (){ Alamofire.request(.POST, strUrl, parameters: param as? [String : AnyObject], encoding: ParameterEncoding.URL).responseJSON { response in switch response.result { case .Success(let data): let json = data as? NSDictionary completionHandler(json, nil) case .Failure(let error): completionHandler(nil, error) self.showSingleAlert("app_name", message: error.localizedDescription) } } } 并在其中设置back button @selector 虽然您需要引用之前的[[[[UIApplication sharedApplication] delegate] window] setRootViewController:previousViewController];,但我不会推荐这种方法。正如@lumialxk所说,请改用viewController

相关问题