【问题标题】:can not scroll table up and down after using animation and a navigation bar disappears使用动画后无法上下滚动表格并且导航栏消失
【发布时间】:2012-02-04 15:38:21
【问题描述】:

我的第一个视图包含一个按钮,按下按钮后,我将看到第二个视图。我所做的是

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 是一个 UIViewController 使得:

SecondViewController.h:

@interface SecondViewController : UIViewController

SecondViewController.m

self.navigationController.navigationBarHidden       = NO;
self.navigationItem.hidesBackButton                 = NO;
self.navigationController.navigationBar.tintColor   = [UIColor blackColor];

发生的事情是顶部导航消失了,我的第二个视图中的 UITableView 无法上下滚动。每当我尝试这样做时,我的程序就会崩溃。

请就这个问题给我建议。这里欢迎任何 cmets。

【问题讨论】:

    标签: iphone objective-c uinavigationcontroller


    【解决方案1】:

    首先它更容易不addSubview: 只需使用此代码来翻页:

    - (IBAction)myCart:(id)sender; {
    viewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:viewController animated:YES];
    
    }
    

    这将允许您的 tableView 滚动!此外,您的方法返回类型为 void,如果您使用按钮调用此方法,则需要将返回类型更改为适用于按钮的 IBAction

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-04
      • 2015-06-14
      • 2020-07-14
      • 2013-07-04
      • 1970-01-01
      • 2019-11-29
      • 1970-01-01
      相关资源
      最近更新 更多