iPhone: UiNavigationController back button [duplicate] - iphone

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to tell when back button is pressed in a UINavigationControllerStack
When I press the back button, what Delegate method is called?

UINavigationBarDelegate is the delegate class and it implements -navigationBar:shouldPopItem, since these controllers work in stacks you're just pushing or popping views. This will most likely always evaluate to true otherwise I feel a back button that does anything but pop a view controller will violate Apple's Human Interface Guidelines.

I agree with elsurudo, the - (void)viewWillDisappear also gets called when you go to a third ViewController, but maybe you want your connection to exist in the Third View Controller but not in the First View Controller. So you might want to detect when the user goes back from the Second View Controller so you can disconnect properly.

Related

Swift: Navigation Bar is not a button [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 months ago.
Improve this question
Hiii !
it's my second app on Xcode.
I noticed that my navigation item is not a button but a "drop down" and I don't know why
How can I change it ? Image: navigation item
So from the comment, I will answer detail about your problem for futher reader and yourself.
As Swift there is two types of tranfering to from view controller to another view controller
First one is using presentViewController which is presents a view controller modally. Just like from your image and we usually use it for task you don't want user to navigate from so just two methods cancel or continue. Example: Sign In, Sign Up, ...
Second one is using pushViewController which will have a Back button just like you want in the navigation bar. And in this case you can control your own controller, callback, ... Remember to define what is root view controller by using Embed in Navigation controller if you use storyboard or define by code by using
UIApplication.shared.windows.first?.rootViewController = vc // your view controller
What you're dealing with is that your storyboard or screen is as a sheet.
Segue set as Page Sheet
Changing this to full screen will give it a bar, but you may need to embed the scene into a navigation control to create a bar. You can do that via Editor -> Embed In -> Navigation Controller.
Segue set to full screen
Embedded into Navigation Controller
The navigation controller color is set to black to be noticeable.

Life Cycle Methods not getting invoked when we dismiss modals in iOS13 [duplicate]

This question already has answers here:
Detecting sheet was dismissed on iOS 13
(13 answers)
Closed 3 years ago.
Apple introduced card style presentation with iOS13 i.e (https://medium.com/#hacknicity/view-controller-presentation-changes-in-ios-13-ac8c901ebc4e). With this change all pagesheets and formsheets will show up as card with a feature to dismiss as swipe that apple gives us. Now we have two ways to dismiss the app.
Dismiss with swipe
Dismiss by clicking close/cancel button on presented controller
The things affected by this change. Since view is no longer removed from hierarchy, life cycle methods like (viewWillAppear, viewDidAppear, viewWillDisappear, viewDidDisappear) won't be invoked on the presentedViewController.
I have several modals in my app. Is there a better way to handle this situation where my life cycle methods get invoked instead of writing delegates throughout the app and calling them only for iOS13 as earlier versions they will get invoked.
Also tried setting isInModalPresentation = true which will stop the dismissing functionality. But, Dismiss by clicking close/cancel button on presented controller will still not call life cycle methods in the presenting view controller.
I don't want them to force them to fullscreen as well.
The uiadaptivepresentationcontrollerdelegate methods are called only if user dismisses via swipe. So need a better way to handle the delegates instead of changing code throughout the app.
Use secondViewController.modalPresentationStyle = .fullScreen before presenting the secondViewController controller.

Navigation Controller design for multiple duplicate views

I'm having a hard time understanding what approach I should take. I have a TableView controller with a list of questions, if you click a row it pushes a new QuestionViewVontroller that displays the question, answers, and next button (or done button). When a user clicks next I want to load the next question (from the tableview list) but I still want the navigation to work (back button will take you to TableView).
I'm starting to think I should keep the same QuestionViewController and just load in the question data. Is this right? Or should I use a modal view?
You have a couple of options here.
Use the same QuestionViewController and just repopulate it, like you mentioned.
Push a new QuestionViewController and use custom back button that either pops to the root view controller or pops to a given view controller.
The code for both options in #2 is below, where "self" is the current view controller (your question controller).
[self.navigationController popToRootViewControllerAnimated:YES]; //this would pop to your UITableViewController, assuming it was the root
[self.navigationController popToViewController:yourTableViewControllerHere Animated:YES]; //this would work as long as you passed a reference to your UITableViewController to your question controllers
It's up to you how you choose to solve your issue. However, if you decide to use the same QuestionViewController, include a catchy animation when importing the new question so the user knows what is happening and to make your app that much cooler :)

What is the picker pattern used in the iphone calendar app? NOT a UIPickerView question

Sorry another newbie question that I couldn't seem to find an answer to on google. Guess I don't know how to describe it well enough.
On the calendar app for the iphone, when you go to add an event, if you select from the repeat, invitees, alert sections and so forth, you are brought to a screen with some choices for the field.
Is this simply navigating to a new view controller on the tap which displays these choices, or is there an pattern that you can implement for this out of the box?
It's just a garden-variety UITableViewController that's pushed onto the navigation controller's stack.
It's probably passed either a reference to the event object or a delegate it can send a message to to set the selected value when "Done" is tapped.

switching between views in iphone programming [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
View Controllers: How to switch between views programmatically?
i want to go to another view from one view on a button click
please help me........
thank you
Use a UINavigationController to display the first view. When the user taps your button, call the navigation controller's pushViewController:animated: method. To return to the previous view programmatically, call one of the pop...ViewController... methods (though this may not be required, since the navigation controller itself can handle "back" button taps).
If you don't want to use the uiNevigationController then use:
[self.view addSubView:objectOfSecondPage.view];
and add this on the back button in the next page
[removeFrom SuperView];