Animate colour changes of background to different View Controllers at same time - ios

I have 3 different ViewControllers that are inside a combination of methods to get one result. During the process I need to change smoothly with some kind of animation the background colour dynamically to show possible different user behaviours. The question is:
Is there any way to change all backgrounds at same time or will I need to check what colour I have each time in each one and pass it to the next view controller and continue the animation there?

If you're asking if you can change the background on view controllers that are not yet loaded or on view - you can. However you need to pass the info to the view controller when you're about to display it on screen to the user. Then change colours in viewWillAppear or ViewDidLoad.

If your viewcontrollers are loaded. You can use NSNotification.
look this link
Send and receive messages through NSNotificationCenter in Objective-C?
Wherever you want to change color write the receiveNotification code in viewDidLoad and call a method with it.
May be it will work for you.

Related

Register for remote notifications in navigation controller

I have many different views in app. While the application state is active I would like to have a generic response to remotenotifications that is not an alertview. One way to do this would be to place the notification observer in uinavigationcontroller rather than in the different view controllers and then place the notification element in navigationcontroller.view. However, thus far nothing appears in navigationcontroller.view when I try to add a label there. Has anyone had success doing this?
If I understand correctly, it seems like you want to show a view whenever your app receives a remote notification and you want to be able to display the view from anywhere inside the app. If this is correct, the best approach would be to create a new UIWindow object and display that as an overlay on top of your app's main window. This answer describes how to create a UIWindow and display it. Additionally, this library does something similar to what you're trying to accomplish.

Multiple States in Xcode 6 Storyboard. Animating/Moving items in run time

I have made various attempt to go storyboard only and limit my code when it comes to UI. Everytime I was getting stuck and reverting back to code. Since the release of XCode 6 and the new iPhone that have multiple screen sizes it make more sense that ever to go Storyboard only.
This time I am stuck on the following scenario. I want to create a custom search view controller that will have 2 states:
Search State. It will prompt the user for a keyword to search.
Result State. It will display the results to the user.
I am aware that this can be accomplished using the UISearchController, but the customer wants to customise the behaviour. Currently I have two view controllers and a push/show segue between them. I would like to replace that with one view controller and animate the display of the results.
Is there any way that storyboard can accomplish that. I am thinking of creating two view controllers (in storyboard) with different layouts. Both will be linked on the same class. I could create a segue between them, but then I will lose all the variable stored inside them and will not be able to animate between them.
On the transition between the two states some UI elements will be hidden and some others will be moved. I would like that to be animated.
I know how to do that in code without using storyboard, but then I will have to cover all different screen scenarios. I hope there is an alternative way.
You can do this with two view controllers, and set a segue between them. The trick is that the animation bit will have to be done in code, unless you write a custom UIStoryboardSegue to handle the animation.

Possible to update a UIViewController that is not on screen?

I have a side menu controller that is part of the rootViewControllerI never remove it from there and when it slides off screen - its just an animation that updates its frame details.
Is it possible to update this view, while it is not displayed on scene? I have a UiTableView in there and I would like to reload it while it is off screen - so when the user slides out the screen, its already populated with new content.
My first approach was a delegate - however, the delegate method doesn't get fired and I believe this is due to it being off screen. But, I somehow think side its in UIWindow it is never really deallocated like a normal view when it leaves the screen?
Edit
I am using this Github project for the menu.
The view I want to update is in a UINavigation controller, one level deep. I can get the current instance of it - however, the delegate method doesn't trigger.
It seems to me that you are going with something like this. Even if not, look at the example. Here RootViewController is always alive and you move one viewcontroller to parent view controller and remove other one.
I have two ways to fix it:
If you are removing first view from parent view controller. Don't remove it. So the controller is still live and use delegates to trigger the event.
Remove first view controller then use Root view controller to get the updates and once the previous view controller loads back take updates from root view controller and update this one.
Hope it can atleast give you an idea.

What's the proper way to implement complex custom view controllers

Note: I'm not talking about custom view controller transition effects which can be done by using a custom view controllers it's the iOS 5+ API.
I'm talking about transitioning to another view controller, where a view from the presently displayed view controller is animated to the view controller to be presented's view.
EXAMPLE
-you have friendsViewController which displays a list of the current users friends. Each table view cell has a profile picture and name.
-click on a cell, all other cells fade away and the name and picture animate to the top. At this point, UserProfileViewComtroller is displayed.
THEORIES
-I could easily do this by combining the two view controllers, but UserProfileViewComtroller can be launched from other parts of the app.
-if the UserProfileViewControllers view is instantiated, I could convert the coordinates using UIViews methods
I feel like there is a more appropriate/cleaner solution here which is why I'm asking the community for help :)
It seems to me that what you want is exactly about view controllers transition, since you want to do 'something' that would look to the user as if you took a view from old VC and moved it to the new VC.
Then you're in luck, as you're allowed to move a UIView from one view controller to another using [superview addSubview:view] as part of the transition you want to do.
This can be done on any iOS version, although it's easier now as in iOS 7 there's a delegate you write (see <UIViewControllerAnimatedTransitioning> reference) which has access to both VC's view hierarchies and can change them at will (move one view, fade other views) during transition period.
Also, making your new view controller during the transition transparent (or using old controller's snapshot) will help you hide the fact that VC changed.
Not so much an answer but a technique that might inspire a solution. I did an app that had need for a custom transition like this. The original app arranged itself then took a snapshot, so at the last moment the user is looking at an image. The second viewController was created, given coordinates etc, and the image, then shown immediately. It put the image into its view (subview with same bounds).
At this point the second vc has complete control, and can fade in some other content etc. the reverse was more or less as the start - the image is used, swapped, used removed to uncover the real view content.
Note that this took a bit of time to get it working with no glitches etc.
EDIT: if you are concerned in turning the whole original view into an image, then modify the technique. For instance, in the original view, fade all other content to black but the cell, then snapshot the one cell. The second view will start with an all black background, and place the cell image over top it, then go from there.
EDIT2: As mentioned in the comments, you of course push the second view with no animation, so it happens instantaneously. By setting a small image on the second vc, with an agreed upon background, you can quickly "pass the baton" so to speak and let the second controller go to work quickly and seamlessly.

Single background image for multiple UIViewControllers

I've created a simple navigation application, which alternates between two views through the use of push/popViewController. I've decided to add a background image, rather than a pattern or single colour, to both view controllers.
Is there a way to have the same backgrounds for both views, without them scrolling when the view changes? This way, it will look like the background stays still, while everything else slides over the top.
I haven't found any help on this issue, and the only idea I've come up with up to now is to attempt to use the app delegate (or, tenuously, the navigation controller) to draw the background, but my attempts to do such have all failed terribly.
Maybe try to add image to application window and set background color for both viewcontrollers to clearColor.
You could use a "root" view controller that manages all other view controllers in your app.
Create a view controller (with the background image as its view) and add it to the window.
Instantiate your navigation controller and then [rootVC.view addSubview:navController.view].
Caveat: This should work, but "nesting" view controllers like this isn't really good practice. Read the discussion Abusing UIViewControllers, and search for "UIViewController Containment" for how to do it properly in iOSĀ 5.

Resources