Showing posts with label storyboard. Show all posts
Showing posts with label storyboard. Show all posts

Saturday, February 18, 2017

Thursday, February 9, 2017

Tuesday, October 11, 2016

Table Headers and Footers

Drag and drop UIViews on to a UITableView on the storyboard.
Tip: Add a prototype cell to the table view first. Then drag and drop the UIView above the prototype cell for a header or below the prototype cell for the footer.

You can then remove the prototype cell after you are done adding the header and/or footer.


(Xcode 8, Swift 3.0)

Saturday, June 4, 2016

Modal Popups on iPhone

The way to achieve the look of a modal popup on the iPhone lies in the settings of the Storyboard Segue from the view controller that will be triggering the popup to the view controller that contains the popup.

I choose Cross Dissolve for the Transition so the popup doesn't slide into view but materializes into view on top instead.

You can do all this in just one view controller but I did it this way to reuse the popup in many view controllers and I like the simplicity of it.

For the modal popup view controller I will sometimes add a blur effect or a view with a lowered alpha property so you can still see the underlying screen a little and then put the content in a smaller size.
Here is an example:

View Hierarchy

If you don't get the right view hierarchy, the transition will be messed up.

Wrong Way

Right Way


Close the Popup

Finally I want the user to be able to touch anywhere off the popup to dismiss it. This can be done by adding a Tap Gesture Recognizer or a button with no text to cover the whole screen below the popup's view.

(Xcode 8)

Navigation

Here are some ways to programmatically control navigation.
In order to find your view controllers by identifier you will have to first set the identifier (after selecting it on the storyboard):

With NavigationController

 
// Navigate to another view controller
let vc = storyboard?.instantiateViewControllerWithIdentifier("myViewController")
navigationController?.pushViewController(vc!, animated: true)

// Go to previous view controller
dismissViewControllerAnimated(true, completion: nil)

// Go to the starting view controller
navigationController?.popToRootViewControllerAnimated(true)
 

Without NavigationController

 
// Navigate to another view controller
let vc = storyboard?.instantiateViewControllerWithIdentifier("myViewController")
present(vc!, animated: true, completion: nil)

// Go to previous view controller
dismissViewControllerAnimated(true, completion: nil)
 

With Segue

 
// Navigate to another view controller
// You have to give your Segue an identifier to use this
performSegue(withIdentifier: "mySegue", sender: self)
 

(Swift 2.2)

SwiftUI Search & Filter with Combine - Part 3 (iOS, Xcode 13, SwiftUI, 2...

In part 3 of the Searchable video series, I show you how to use Combine in #SwiftUI for the search and filter logic connected to the searcha...