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)
不工作....有什么不对?