Showing posts with label viewController. Show all posts
Showing posts with label viewController. Show all posts
Tuesday, 25 February 2014
View Controller Transitions iOS7
If you like to learn about animatedtransitioning this is the best blog that I have find, explains it very well: http://www.objc.io/issue-5/view-controller-transitions.html
View Controller Transitions
Issue #5 iOS 7, October 2013
By Chris Eidhof
One of the most exciting iOS 7 features for me is the new View Controller Transitioning API. Before iOS 7, I would also create custom transitions between view controllers, but doing this was not really supported, and a bit painful. Making those transitions interactive, however, was harder.
Before we continue with the article, I’d like to issue a warning: this is a very new API, and while we normally try to write about best practices, there are no clear best practices yet. It’ll probably take a few months, at least, to figure them out. This article is not so much a recommendation of best practices, but rather an exploration of a new feature. Please contact us if you find out better ways of using this API, so we can update this article.
Before we look at the API, note how the default behavior of navigation controllers in iOS 7 changed: the animation between two view controllers in a navigation controller looks slightly different, and it is interactive. For example, to pop a view controller, you can now pan from the left edge of the screen and interactively drag the current view controller to the right.
That said, let’s have a look at the API. What I found interesting is the heavy use of protocols and not concrete objects. While it felt a bit weird at first, I prefer this kind of API. It gives us as programmers much more flexibility. First, let’s try to do a very simple thing: having a custom animation when pushing a view controller in a navigation controller (the sample project for this article is on github). To do this, we have to implement one of the new UINavigationControllerDelegate methods:
- (id<UIViewControllerAnimatedTransitioning>)
navigationController:(UINavigationController *)navigationController
animationControllerForOperation:(UINavigationControllerOperation)operation
fromViewController:(UIViewController*)fromVC
toViewController:(UIViewController*)toVC
{
if (operation == UINavigationControllerOperationPush) {
return self.animator;
}
return nil;
}
Read the rest of the article here : http://www.objc.io/issue-5/view-controller-transitions.html
Wednesday, 1 May 2013
View Controller Lifecycle
View Controllers are the controllers of your MVC. They have a Lifecycle. (They are created, do some task and they die.)
There are certain methods in view controller which notify you of what's going on. View controller can be created by alloc init by 99% of time MVCs are instantiated out of a story board.
Put set up codes for your view in viewDidLoad:
-(void) viewDidLoad{
[super viewDidLoad];
}
But remember geometry is not set in viewDidLoad. You can do it in viewWillAppear:
-(void)viewWillAppear: (BOOL)animated;
Your view will only load once, but it may appear and disappear few times.
If your things you are displaying is changing while your app is off screen, you should add the code to viewWillAppear.
didRecievedMemoryWarning
In low memory situation, didRecievedMemoryWarning is called. It is very rare to happen, but if it happens you can set the pointer of the object that causes it to nil and reload your data. Keep in mind to use caching in your program where it makes sense.
awakeFromNib
This message is sent to every single object that comes out of the story board. It happens before the MVC is loaded and before all the outlets are set.
There are certain methods in view controller which notify you of what's going on. View controller can be created by alloc init by 99% of time MVCs are instantiated out of a story board.
Put set up codes for your view in viewDidLoad:
-(void) viewDidLoad{
[super viewDidLoad];
}
But remember geometry is not set in viewDidLoad. You can do it in viewWillAppear:
-(void)viewWillAppear: (BOOL)animated;
Your view will only load once, but it may appear and disappear few times.
If your things you are displaying is changing while your app is off screen, you should add the code to viewWillAppear.
didRecievedMemoryWarning
In low memory situation, didRecievedMemoryWarning is called. It is very rare to happen, but if it happens you can set the pointer of the object that causes it to nil and reload your data. Keep in mind to use caching in your program where it makes sense.
awakeFromNib
This message is sent to every single object that comes out of the story board. It happens before the MVC is loaded and before all the outlets are set.
written by: infinitywebseo
Labels:
alloc,
bool,
Geometry,
init.,
lifecycle,
MVC,
viewController,
viewDidLoad
Subscribe to:
Posts (Atom)