【问题标题】:How to make sure that viewWillLayoutSubviews / All View Calls have been made?如何确保已进行 viewWillLayoutSubviews / All View Calls?
【发布时间】:2014-10-27 21:47:40
【问题描述】:

我有以下情况,我想在自动布局中设置按钮后将其设置为隐藏。

所以基本上,假设这个方法称为- (void) hideSomeButton。我将此方法称为:

BlahViewController *bVC = [[UIStoryboard storyboardWithName:"Blah"] instantiateInitialViewController];
[self.navigationController pushViewController:bVC animated:YES];
[bVC hideSomeButton];

我假设这就是方法调用应该是的:

1. init Method
2. viewDidLoad
3. viewWillAppear
4. viewWillLayoutSubviews (This has an explicit call making someButton.hidden = NO)
5. viewDidLayoutSubviews
6. hideSomeButton (This has an explicit call making someButton.hidden = NO)

但是,`viewWillLayoutSubviews' 被调用了两次。因此,会发生什么:

1. viewWillLayoutSubviews - Button Shown
2. hideSomeButton - Button Hidden
3. viewWillLayoutSubviews - Button Shown

轰!没有隐藏按钮!请帮忙。

【问题讨论】:

    标签: ios uibutton viewwillappear


    【解决方案1】:

    为什么在调用 [super viewWillLayoutSubviews] 之后不从 BlahViewController 中的 viewWillLayoutSubviews 调用 hideSomeButton 而不是在 bVC 上调用它?

    【讨论】:

      猜你喜欢
      • 2023-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多