我添加视图在我的主视图像这样的工作:removeFromSuperView不会在iOS 8
self.voteResult = [[voteResultViewController alloc]initWithNibName:@"voteResultViewController" bundle:nil];
UIWindow* mainWindow = [[UIApplication sharedApplication] keyWindow];
[mainWindow addSubview:[self.viewControllerForPresentation view]];
[self.viewControllerForPresentation presentViewController:self.voteResult animated:YES completion:Nil];
然后用此将其取出:
[self.viewControllerForPresentation.view removeFromSuperview];
作品中的iOS 7,但在iOS 8中不再更长,我需要做不同的事情吗?
你为什么要自己添加视图,还要使用'-presentViewController:animated:completion:'?该方法呈现视图控制器,这应该使视图适当地显示。然后你应该使用'-dismissViewControllerAnimated:completion:'来关闭控制器,这也将删除视图。 – Caleb 2014-11-03 14:57:32