hi I have a view controller with a container and in the container a child view with a collection view when the user taps the collection view cell it sends me to detail view controller but now what i want to do is to add a back button in my detail view controller which sends me to the parentViewController
相关问题
- 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
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
- Attempt to present UIAlertController on View Contr
On Back button action, add this line:
This will move you to
rootViewController
.If you want to customise the back button, first hide the navigation bar
[self.navigationController setNavigationBarHidden:YES];
Now add a button, and create its touchUpInside event, in that event pop the controller
[self.navigationController popViewControllerAnimated:YES];
Case 1 : Unwind Segue
This will work perfect according to your situation:
iOS Unwind Segue
Unwind Segues give you a way to “unwind” the navigation stack and specify a destination to go back to.
Case 2 : PopToRootViewController
If you Parent view is also your Root view controller, then you can easily get back using
popToRootViewControllerAnimated:YES
.Create own back button add it to navigation bar with method
backButtonTouch
.Add above code into
viewDidLoad
.Here is my code to go back to parent view controller