我有导航控制器和根视图。然后在那个根视图中,我按下了一个视图,我必须单击才能观看内容,如果没有登录,它将打开一个带有以下代码的模态视图控制器。
var vc = self.storyboard?.instantiateViewControllerWithIdentifier("LoginViewController") as! LoginViewController
self.tabBarController!.presentViewController(vc, animated: true, completion: nil)
在viewdidload()中我有一个nsnotification,以便在用户从登录模式登录时收到通知
NSNotificationCenter.defaultCenter().addObserver(self, selector: ("didDismissSecondViewController:"), name: "SecondViewControllerDismissed", object: nil)
在登录控制器完成所有工作后,我编写了以下代码
self.dismissViewControllerAnimated(true, completion: {NSNotificationCenter.defaultCenter().postNotificationName("SecondViewControllerDismissed", object: nil, userInfo: nil)});
所以在我的第一个视图控制器中,我编写了以下代码
func didDismissSecondViewController(sender: AnyObject)
{
NSLog("Called ns notifications")
dispatch_async(dispatch_get_main_queue(),{
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
if Reachability.isConnectedToNetwork() == true {
let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc : VideoPlayViewController = storyboard.instantiateViewControllerWithIdentifier("video") as! VideoPlayViewController
vc.movieUrl = self.movieURL
NSLog("URL:- \(self.movieURL)")
let navigationController = UINavigationController(rootViewController: vc)
self.presentViewController(navigationController, animated: true, completion: nil)
}
else
{
var alert = UIAlertView(title: "No Internet connection", message: "Please ensure you are connected to the Internet. Connect to internet and and choose any sorting option to reload.", delegate: self, cancelButtonTitle: "Cancel")
alert.addButtonWithTitle("Ok")
alert.show()
}
})
}
但是,当它在解除登录控制器后尝试显示视图控制器时,它会显示"不鼓励在分离的视图控制器上显示视图控制器"错误,它崩溃了。
答案 0 :(得分:0)
感谢上帝,我找到了答案!!!
foreach (var f in files)
{
using (Bitmap b = (Bitmap)Image.FromFile(f))
{
//Do some work
}
}