Showing a view within another view in Xcode - objective-c

Let's say I have three views: A, B, and C. I'm on view A and there is a button that says "Show view C". Now I want when choosing that button for the active view to go to B, and then display view C as a popup on view B. That's the first question. The second question: how can I make view C into say a 500x500px popup that I can design in an in XIB file (where this popup will appear over view B)?

It really depends on how your application is designed. IF you have UIViews (I would imagine at least one UIViewController) then you could for instance design view A in interface builder adding view B as a subview (on top of) view A. Then add view C on top of view B. Then set the size and position of view C to 500x500px and move it to where you want it to be on view B. Of course you need to add IBOutlets to your headers and hook each view up to its IBOutlet. Then, the cheap way would be to simply set hidden=YES for the B or B and C views. When the user presses a button, you simply unhide view B and then unhide view C. If you used UIViewControllers and had a UINavigationController, you could set A's view controller as the root view controller and simply push B's view controller. Then from B you could presentModalViewController. It really depends on how your application is designed.

Related

How to delete "Duplicated" views

I have my main view that has 3 UIButton that sends to 3 other views, I also have a slide menu (like the one used by facebook app) that has another 3 buttons that sends to the same 3 views of the buttons on the main view. I go to the views with a segue method, the problem is that using the buttons on the slide menu I create duplicates of the view (e.g if i press twice on the second button i'll create 2 identical views) is there a way to delete duplicated views that uses segue method?
if u know the names of the view u can always call
[myView removeFromSuperview]; method to remove your view that is u are creating dynamically so yeah u can remove it like this,
hope it helps

how to go back to the current previous view in one controller's button action in ios

I am trying to do if user give correct password it will go back to the current last view controller where i was,like in Ios if u enter background in your app and after sometime you enter foreground then you will go back to the last view i.e where you was before entering background.please tell me how to implement this.
if you want to pop to the root controller you can use popToRootViewControllerAnimated.
[self.navigationController popToRootViewControllerAnimated:YES];
From Apple doc of UINavigationController
popToRootViewControllerAnimated:
Pops all the view controllers on the stack except the root view controller and updates the display.
- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated
If you have set up a UINavigationController and its root controller is called A, then if you navigate from A to B and then from B to C you have two possibilities to come back to a previous controller (you can have others but I list the main ones):
navigate back from C to B with popViewControllerAnimated
navigate back from C to A with popToRootViewControllerAnimated
I would suggest using a modal view controller that is not actually added to you parent controllers hierarchy (child view controllers) and can be shown and dismissed at your discretion take a look here for a great example.

How to play different animation on a view?

I have an issue in Sencha Touch 2.
Working with routes is pretty cool but I have a question.
In my view A I have one button which redirects you to view "B".
Controller of A just calls: redirectTo('routeB').
Controller of B calls method "active". This method sets B as active
item.
In view B I have a button, too which redirects you to View C.
Okay. The back button of view C just calls redirectTo('routeB').
As you can see two view redirects to the view B.
I want view B to slide right if I came from C and just pop if I
come from A.
Remember A and C just do redirectTo(). Setting B as active
item is the job of the Controller of View B in method "active".
How can I play the right animation in active method?
Take a look at the animateActiveItem
use the following code it may help you.
Ext.getCmp('panelId').animateActiveItem(1, {type:'slide', direction:'left'});
Take a look at getShowAnimation() it may help you.

Make a view to be the primary one in navigation controller?

I am using a tabbar, each tab having a navigation controller, and this in turn having a stack of views. Each view is having its own view controller but this is not important now.
Lets have a tab 1 with a navigation controller 1 with views A, B, C.
The nature of the application dictates however that the view B is the primary one.
So what I want is that by default (after first or after relaunch of the app), when I tap the tab 1, I will see the B view together with the back button to A view.
How can I achieve this?
You can set up a delegate for your tab bar controller and implement tabBarController:didSelectViewController: to detect when someone taps a tab. If you detect that A is about to be selected and you want B to be displayed instead, you can tell A's controller to use its navigation controller to push B's controller.
Try initializing and pushing view B (without animation) onto the navigation stack in viewDidLoad of view A.
You could use the setViewControllers:animated: of UINavigationController.
Depending on your exact needs you could set this in your app delegate applicationWillEnterForeground: or applicationDidBecomeActive: methods.
I recall there being an Apple sample app that does exactly this. The general idea is to save the last visible view controller (or just hard code the one you want) and then push it to the visible state using something like so:
[myNavigationController pushViewController:viewControllerToBeVisible animate:NO];
You'd want to show the apps tabBarController:didSelectViewController:, and handle the different cases based on which viewController was selected.

ios - splitviewcontroller inside tabbarcontroller using storyboards

I have my app mapped out using storyboards where there is an entry screen that segues to a tabbarcontroller which contains 3 tabs. Each tab contains a splitviewcontroller and I have written classes for each master and detail view controller. The bit I'm not sure on is how to give each masterviewcontroller (that controls the table on the left hand side) a reference to the detailviewcontroller.
I can see in the attributes inspector there is an identifier field, should i put something in here for the detailviewcontroller (e.g. 'detailviewcontroller1) and then somehow get that object by it's instance name in code?
Both your master and detail view controllers will have a property, splitViewController, that holds a pointer to the split view controller.
The split view controller has a property, viewControllers, which holds an array of the view controllers contained in the split view. This array will always contain 2, and only 2, view controllers - at index 0 is the master controller, and at index 1 is the detail controller.
So your SplitViewController should be connected to 2 segues that connect two separate UINavigationControllers (one for Master and one for Detail). These two nav controllers will connect to your two VC's (Master and Detail).
You will then create a property for that detail VC inside the master VC and pass whatever data you need to when the user selects a row from the TV.
If you need to see how this is supposed to be layed out and wired up, just create a new iPad application using the Master-Detail template.