can not scroll table up and down after using animation and a navigation bar disappear

Discussion in 'iOS Programming' started by tranvutuan, Feb 4, 2012.

  1. macrumors member

    Joined:
    Dec 19, 2011
    #1
    My first view contains a button and after pressing a button, i will end up with the second view. what I have done is
    Code:
    FirstViewController.m
    - (void)pushToWishList
    {
        SecondViewController *controller = [[SecondViewController alloc] initWithNibName:@"SecondView" bundle:nil ];
        
        [UIView beginAnimations:@"flipping view" context:nil];
        [UIView setAnimationDuration:1];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
        [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
        [self.view addSubview:controller.view];
        [UIView commitAnimations];
    }
    SecondViewController is an UIViewController such that :
    Code:
    SecondViewController.h
    @interface SecondViewController : UIViewController <UITableViewDataSource,UITableViewDelegate>
    Code:
    SecondViewController.m
        self.navigationController.navigationBarHidden       = NO;
        self.navigationItem.hidesBackButton                 = NO;
        self.navigationController.navigationBar.tintColor   = [UIColor blackColor];
    What is happening is the top navigation is disppearing and the UITableView in my second view can not be scrolled up and down. My program is crashed whenever I try to do this.

    Please advice me on this issue. Any comments are welcomed here.
     
  2. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Your method is called pushToWishList. Why are you not pushing the new view controller onto your navigation stack?
     
  3. thread starter macrumors member

    Joined:
    Dec 19, 2011
    #3
    because I want to do an animation such that the next page will curl down
     
  4. macrumors 6502

    Joined:
    Jul 14, 2008
    #4
    You can still do that by replacing the line that adds the controller's view as a subview with pushing that view controller onto the stack.
     
  5. tranvutuan, Feb 4, 2012
    Last edited: Feb 4, 2012

    thread starter macrumors member

    Joined:
    Dec 19, 2011
    #5
    Did you meant like this
    SecondViewController *controller = [[SecondViewController alloc] initWithNibName:mad:"SecondView" bundle:nil ];

    [UIView beginAnimations:mad:"flipping view" context:nil];
    [UIView setAnimationDuration:1];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
    [self.view addSubview:controller.view];----------> [self.navigationController pushViewController:controller animated:YES];
    [UIView commitAnimations];

    Are you sure that it works. I tried and my program crashed
     

Share This Page