How to play different animation on a view? - sencha-touch-2

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.

Related

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.

Which event is called after the view is shown

I have created a small app with a storyboard.
Now, I have created a first view, which should be my splash. I am now searching for the right place to put my work into it. After this work, I would programmatically triggering a Storyboard Segue to switch to the next view. For this, I am searching the right place/event. It should be an event which is called right after the view will be shown.
I have tried viewDidLoad but it seems, that this event is triggered before the view is shown on the screen.
The (void)viewDidLoad method is called the 1st time the view is loaded.
So it's the good place where to write your init/setup lines.
The (void)viewDidAppear: method is called everytime your view is displayed.
Hope this helps.
Actually, and for a little nitpicking here. viewDidAppear is not called every time a VC is shown, but each time it is inserted in the VC hierarchy. So it seems to be what you want to use for now. But if you have later some use case where you want some action to take place each time the view is displayed to the user you need other means. For example this method will not be called when you push back some navigation VC (your VC is already in the hierarchy).

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.

Issue with UINotification in iOS / objective C

I am making an app with different nav controllers. All of them are initially initialized.
Say, I have 3 nav controllers A, B and C.
A View controller from B (say B1) sends a notification that is supposed to be heard from view controller in A (say A1). After that, we go to view controller A1.
However, if we are in the view controller B1 from the beginning (and never went to View controller A1), then A1 doesnt get the notification. However, it gets it the second time.
OR, if I go inside A1 once, then the notifications are properly received.
Can anyone kindly help me out ? Thanks.
NB: the listeners code is in the init of A1. It gets hit (i checked by using breakpoints).
Since you're saying the notification is received after the view is displayed once, my suspicion is that you are registering for notifications in a method that isn't run until the view is displayed (viewDidLoad, viewDidAppear:, etc.).
If this is the case, try moving your notification registration to whichever init method that you're using in the ViewControllers.
NSNotification is observable through all the app. So, to do what you plan to do, I would use a boolean flag or a counter. You can put those indicators in the appDelegate class or use a global variables.

Showing a view within another view in Xcode

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.