2014-06-25 31 views
0

在我的示例代码中,我使用UINavigationController。我有保存新的数据到核心数据UIViewController,那么我要关闭这个UIViewController并返回上一级:Swift中的UINavigationController

@IBAction func saveButtonPressed(sender : AnyObject) { 

    let appDelegate:AppDelegate = (UIApplication.sharedApplication().delegate as AppDelegate) 
    let context:NSManagedObjectContext = appDelegate.managedObjectContext 
    let projectEntity = NSEntityDescription.entityForName("Person", inManagedObjectContext: context) 
    var newPerson = AddrBook(entity: projectEntity, insertIntoManagedObjectContext: context) 
    newPerson.lastname = lastNameField.text 
    newPerson.firstname = firstNameField.text 
    context.save(nil) 
    self.navigationController.dismissViewControllerAnimated(true, completion: nil) 
} 

self.navigationController.dismissViewControllerAnimated(true, completion: nil)不工作....有什么不对?

回答

0

对不起!我解决了问题:

self.navigationController.popViewControllerAnimated(true) 
相关问题