I am brand new in Xcode and iOS development. I am trying to figure out how to open/show some view based on button click. I know that I can do this using ctrl + mouse click on some ViewController using segue but I need to add some logic before. How can I accomplish this?
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Xcode: Is there a way to change line spacing (UI L
- Swift - hide pickerView after value selected
- Popover segue to static cell UITableView causes co
- How do you detect key up / key down events from a
Read apple documents - start developing apps and view controllers basics
There are two ways to make segues work.
You can either ctrl drag from a button to a new ViewController (like you have done) or you can ctrl drag from one ViewController to a new ViewController (drag from the little orange square icon in the bar underneath the VC).
For both ways you can set an identifier on the segue that gets created. This is used to refer to it in the code.
When you do the first way you are saying "When this button is pressed, move to this ViewController". This means that whenever that button is pressed it will move to the new VC.
The second way just tells the storyboard that there will be a segue to move to the new VC. To run it you would then add a IBAction to your button (instead of the segue).
In the action for the button you then have...
This will then only perform that segue if the condition you have checked is true.
You can also pass information to the new VC like so...
this will then set the property in the new VC before transitioning to it.