On Dec 10, 2010, at 6:52 AM, Tharindu Madushanka wrote:

> Hi,
> 
> I would like to present my next view controller in a way that pushed in. But
> my first view controller is not a navigation controller.
> 
> How could I do this. Is it possible ?

If you want a view to be animated in the same way as a view whose controller is 
pushed on the navigation stack, you may use CATransition. The following code 
shows how you may accomplish this task:

It is assumed, there is a view controller which currently displays its main 
view and a button in it as a subview. The user can tap the button, which causes 
the following action to be invoked:


// MyViewController implementation
#import <QuartzCore/QuartzCore.h>

- (IBAction) onButtonPressed:(id) sender
{
    UIImage* image = [UIImage imageNamed:@"MyFancyImage"];
    UIImageView* imageView = [[UIImageView alloc] initWithImage:image];
    imageView.frame = self.view.bounds;
    [self.view addSubview:imageView];
    [imageView release];
    
    CATransition* transition = [CATransition animation];
    transition.type = kCATransitionPush;
    transition.subtype = kCATransitionFromRight;
    [self.view.layer addAnimation:transition forKey:@"push-transition"];
}


The view originally seen (the controller's main view and the button) will 
appear to be moved out from right to left while a new view containing the image 
will be moved in. The status-bar will stay at its place.

Regards
Andreas

> 
> Thanks and Kind Regards,
> 
> Tharindu

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to