switching between views in iphone programming [duplicate] - iphone

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];

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.

Change Tab Dynamically in iPhone using Storyboard Tabbar Application [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Programmatically pressing a UITabBar button in Xcode
I've four tabs in Main tabbar controller. On 1st Tab, there is "Dashboard" Page which is displayed when User registered with Device-ID.
For non-existing Users, It'll prompt a message for Registration. And By clicking on "OK" button, I want to jump on 4th Tab which is used for Set-Up module.
So, how can I set Tabbar index as done with older earlier versions and navigation in Tabbar ?
Please tell me any Solution.
Thanks in Advance.
Execute the following line of code to get the tabBar begin with the 4 th tab selected when it will be presented
[tabBarController setSelectedIndex:3];
You have to implement this code first If you are using Tabbar based Application in Storyboard.
UITabBarController *tabBar = (UITabBarController *)self.window.rootViewController;
Then,
[tabBar setSelectedIndex:3];
As you said : AppleDelegate

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 :)

How do I create a view(Shows balance) that stays onscreen while I switch between tabs? [duplicate]

This question already has an answer here:
Closed 11 years ago.
Possible Duplicate:
How do I create a view that stays onscreen while I switch between tabs?
i have a tab bar conttoller, i wanted to create a view(it dispalys balance).
I wanted that view to be displayed on top through out my application.
How can create such a view???
this way, you have to put the tabbar inside a view first (you should start with a plain view project or other project except for tabbar project)
so what u want to do is
start with a plain view project (my choice)
in header, put tabbardelegate
in header, create TabBarController variable (for instead : myTabBar)
populate the myTabBar in the implementation file
add the myTabBar to the view by using [self.view addSubView:myTabBar.view]
after you added the tabbar as a subview, proceed into making your new view (the one with balance)
add the new view as a subview of the main parent view
this way, the balance view will place above the tabbar view, meaning, it will always be displayed above the tabBar
its quite simple, really, if u have rather complex codes, you can always insert the subview by index such as :
[self.view insertSubview:theView atIndex:theIndex]
or
[self.view insertSubview:balanceView aboveSubview:myTabBar.view]

iPhone: UiNavigationController back button [duplicate]

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.