2014-06-25 76 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) 
相關問題