为了达到与许多照片应用程序类似的效果我:
我从按钮开始以这种方式启动视图控制器,它可以工作。但是,我不能有效地解雇它。
didFinishLaunchingWithOptions 中的:
var tabBC = UITabBarController()
//....
shutterButton.addTarget(self, action: "presentCamera:", forControlEvents: UIControlEvents.TouchUpInside)
tabBC.view.addSubview(shutterButton)
附加行动:
func presentCamera(sender: AnyObject){
let composeSB = UIStoryboard(name: "Compose", bundle: nil) as UIStoryboard
let composeVC = composeSB.instantiateViewControllerWithIdentifier("composeVC") as ComposeViewController
self.window?.rootViewController!.presentViewController(composeVC, animated: false, completion: nil)
}
在 ComposeViewController 中调用此方法,但视图控制器不会被解除。我认为这会解雇VC,我会在tabbarcontroller中看到这些视图。
func cameraOverlayDidCancel() {
// I've tried:
dismissViewControllerAnimated(true, completion: nil)
//self.dismissViewControllerAnimated(true, completion: nil)
//self.view.parentViewController.dismissViewControllerAnimated(true, completion: nil)
}