【问题标题】:Iphone: Unhiding a Tab bar and Navigation Bar after NavigationIphone:导航后取消隐藏标签栏和导航栏
【发布时间】:2011-04-15 14:57:23
【问题描述】:

我有一个 UItabbarController,在第一个选项卡内有一个 UINavigationController。在界面生成器中,我将标签栏和导航栏设置为隐藏。

当第一个屏幕加载时(这是第一个选项卡的 Uinaviagtioncontroller 中的 UIVewcontroller),我将 NStimer 设置为 2 秒。之后它导航到第二个视图。现在,当这种情况发生时,我希望出现导航栏和标签栏,并且它应该是动画的。

这就是我现在正在做的事情。

第一个 UIViewController:

- (void)viewDidLoad {
    [super viewDidLoad];
    splashTime = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector (action) userInfo:nil repeats:NO];
}

-(void)action{
    SecondViewController *m = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
    [self.navigationController pushViewController:m animated:YES]; 
}

第二个 UIViewController:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        self.hidesBottomBarWhenPushed = NO;
        [self.navigationController setNavigationBarHidden:NO animated:YES];
    }
    return self;
}

但实际上并没有发生任何事情。 Tabbar 或 NavigationBar 都不会出现。

【问题讨论】:

    标签: iphone cocoa-touch xcode uinavigationcontroller uitabbarcontroller


    【解决方案1】:

    尝试将您的 Second View Contoller 的代码放在 viewWillAppear 方法中,而不是 initWithNibName 方法中,看看是否有预期的结果:

    - (void) viewWillAppear:(BOOL)animated {
      self.hidesBottomBarWhenPushed = NO;
      [self.navigationController setNavigationBarHidden:NO animated:YES];
    }
    

    这样每次视图即将显示时都应该调用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-09
      • 1970-01-01
      相关资源
      最近更新 更多