Problem while implementing UIViewAnimationTransitionCurlUp with SplitVIew apps

Discussion in 'iOS Programming' started by nsahay, Mar 24, 2010.

  1. nsahay macrumors newbie

    Mar 24, 2010

    I have develope an application for iPhone using view Animation it is working fine . Please see the code below :

    .m file


    - (void)viewDidLoad
        [super viewDidLoad];
        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        UIBarButtonItem *nextButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(nextViewAction:)];
       [self.view removeFromSuperview];
        view1 = [[Views_Page1 alloc] initWithNibName:@"Views_Page1" bundle:[NSBundle mainBundle]];
        view2 = [[AnimationView2 alloc] initWithNibName:@"AnimationView2" bundle:[NSBundle mainBundle]];
        [self.container  addSubview:view1.view];
    - (void)nextViewAction:(id)sender
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDidStopSelector:@selector(animationDidStop:animationIDfinished:finished:context:)];
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:kTransitionDuration];
        [UIView setAnimationTransition:([self.view1.view superview] ? UIViewAnimationTransitionCurlUp : UIViewAnimationTransitionCurlDown)
        if ([self.view2.view  superview]) {
            [self.view2.view removeFromSuperview];
            [self.container  addSubview:view1.view];
        } else {
            [self.view1.view removeFromSuperview];
            [self.view addSubview:view2.view];
        [UIView commitAnimations];

    It is working fine.

    Same thing when I am trying for iPad application where I have SplitView Controller :

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {   
        // Override point for customization after app launch   
        rootViewController = [[RootViewController alloc] initWithStyle:UITableViewStylePlain];
        rootViewController.managedObjectContext = self.managedObjectContext;
        detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil];
        navigationController = [[UINavigationController alloc] initWithRootViewController:detailViewController];
        splitViewController = [[UISplitViewController alloc] init];
        splitViewController.viewControllers = [NSArray arrayWithObjects:rootViewController,navigationController, nil];
        splitViewController.delegate = detailViewController;
        // Add the split view controller's view to the window and display.
        [window addSubview:splitViewController.view];
        [window makeKeyAndVisible];
        return YES;
    /* In the detail view controller*/
    - (void)viewDidLoad
        [super viewDidLoad];
        frame = CGRectMake(round((self.view.bounds.size.width - kImageWidth) / 2.0),
                           kTopPlacement, kImageWidth, kImageHeight);
        self.containerView = [[[UIView alloc] initWithFrame:frame] autorelease];
        [self.view addSubview:self.containerView];
        // The container view can represent the images for accessibility.
        [self.containerView setIsAccessibilityElement:YES];
        [self.containerView setAccessibilityLabel:NSLocalizedString(@"ImagesTitle", @"")];
        // create the alternate image view (to transition between)
        CGRect imageFrame = CGRectMake(0.0, 0.0, kImageWidth, kImageHeight);
        self.currentPageView = [[[UIImageView alloc] initWithFrame:imageFrame] autorelease];
        self.currentPageView.image = [UIImage imageNamed:@"page1.bmp"];
        [self.containerView addSubview:currentPageView];
        frame = CGRectMake(0.0, 0.0, kImageWidth, kImageHeight);
        self.nextPageView = [[[UIImageView alloc] initWithFrame:frame] autorelease];
    - (IBAction)insertNewObject:(id)sender
        // Code to Flip an image
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:kTransitionDuration];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationTransition:([self.currentPageView superview] ?
                                        UIViewAnimationTransitionCurlUp : UIViewAnimationTransitionCurlDown)
                               forView:self.containerView cache:YES];
        if ([self.currentPageView superview])
            [self.currentPageView removeFromSuperview];
            [self.nextPageView setImage:[UIImage imageNamed:@"page2.bmp"]];
            [self.containerView addSubview:nextPageView];
            [self.nextPageView removeFromSuperview];
            [self.currentPageView setImage:[UIImage imageNamed:@"page1.bmp"]];
            [self.containerView addSubview:currentPageView]; // error I get on AddSubView method.
        [UIView commitAnimations];

    When I am running this app using iPad Simulater I am getting errors : some time 2010-03-24 14:23:27.071 SpilitViewTest[26530:207] *** -[CALayer setImage:]: unrecognized selector sent to instance 0x5229080
    2010-03-24 14:23:27.083 SpilitViewTest[26530:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[CALayer setImage:]: unrecognized selector sent to instance 0x5229080'

    error message is getting chage.

    I am trying to implement the view animation with splitView based application . Pls advise :)
  2. fishkorp macrumors 68020


    Apr 10, 2006
    Ellicott City, MD
    Wirelessly posted (Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_3 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7E18 Safari/528.16)

    First, this should be in the programming forum. Second, topics on iPad programming aren't discussed here due to the NDA.

Share This Page