解除视图控制器

时间:2016-03-17 10:28:52

标签: objective-c iphone uinavigationbar

奇怪的事情

    解除视图控制器后
  • 导航栏' alpha值更改

步骤

  • 单击显示新viewcontroller的按钮
    • 单击按钮时将导航栏alpha设置为0.0
  • 解除我之前提出的viewcontroller。

结果[NG]

  • 导航栏' alpha值设置为1.0

预期结果

  • 导航栏的alpha应该是预期的0.0
  

以下示例非常简单

ViewController类

- (void)viewWillAppear:(BOOL)animated {
    NSLog(@"%s : %f", __func__,   self.navigationController.navigationBar.alpha);
}

- (void)viewDidAppear:(BOOL)animated {
    NSLog(@"%s : %f", __func__, self.navigationController.navigationBar.alpha);
}

- (void)viewWillDisappear:(BOOL)animated {
    NSLog(@"%s : %f", __func__,  self.navigationController.navigationBar.alpha);

}
- (void)viewDidLoad {
    [super viewDidLoad];

    self.navigationController.navigationBar.backgroundColor = [UIColor orangeColor];
    self.view.backgroundColor = [UIColor whiteColor];

    UIButton *clickMe = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 100, 30)];
    [clickMe setTitle:@"clickme" forState:UIControlStateNormal];
    [clickMe setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [clickMe addTarget:self action:@selector(btnClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:clickMe];
 }


- (void)btnClicked {
    self.navigationController.navigationBar.alpha = 0.0f;
    second *sec = [[second alloc] init];
    [self presentViewController:sec animated:YES completion:nil];
}

第二课

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.navigationController.navigationBar.backgroundColor = [UIColor orangeColor];

    self.view.backgroundColor = [UIColor yellowColor];
    UIButton *getBack = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 100, 40)];
    [getBack setTitle:@"getBack" forState:UIControlStateNormal];
    [getBack setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [getBack addTarget:self action:@selector(btnClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:getBack];
}

- (void)btnClicked {
    [self dismissViewControllerAnimated:YES completion:nil];
}

我真的很想知道这件事发生了什么.. 如果有人知道这一点,请告诉我..提前谢谢你。

0 个答案:

没有答案