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