Create Navigation Bar Programmatically in Swift

In your UIPopoverPresentationControllerDelegate: func presentationController(controller: UIPresentationController, viewControllerForAdaptivePresentationStyle style: UIModalPresentationStyle) -> UIViewController? { let presentedViewController = controller.presentedViewController let navigationController = UINavigationController(rootViewController: presentedViewController) let dismissButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Done, target: self, action: “dismissPopover:”) presentedViewController.navigationItem.rightBarButtonItem = dismissButton return navigationController } func dismissPopover(sender: AnyObject) { self.dismissViewControllerAnimated(true, completion: nil) }

Setting Up Delegates in iOS

This is copied from the iOS Apprentice tutorial on raywenderlich.com but I wanted to put it where I could easily access it. These are the basic steps for setting up a delegate pattern between two objects, where object A is the delegate for object B, and object B will send messages back to A. Define a delegate protocol for… Continue reading Setting Up Delegates in iOS

Published
Categorized as tutorials Tagged