简体   繁体   English

触发UIApplicationDidBecomeActiveNotification后会调用什么?

[英]What gets called after UIApplicationDidBecomeActiveNotification gets triggered?

In my app I'm trying to make my navigation bar not shrink from 44px to 32px when the phone is rotated to horizontal orientation. 在我的应用程序中,当手机旋转到水平方向时,我正试图让我的导航栏从44px缩小到32px。 I've been able to accomplish this by setting the navigationBars frame when the view is rotated and also in viewDidAppear. 我已经能够通过在旋转视图时设置navigationBars框架以及在viewDidAppear中完成此操作。 However, when I push the home button to exit the app and then I reenter the app, the navigation bar still shrinks. 但是,当我按下主页按钮退出应用程序然后我重新进入应用程序时,导航栏仍然缩小。 So I implemented a notification to detect UIApplicationDidBecomeActiveNotification, and in that method I reset the navigationBar frame height to 44px. 所以我实现了一个检测UIApplicationDidBecomeActiveNotification的通知,在那个方法中我将navigationBar框架高度重置为44px。 However, it doesn't work because something is getting called which is resetting my views frame. 但是,它不起作用,因为调用了一些正在重置我的视图框架的东西。 Does anyone know what gets called after a UIApplicationDidBecomeActiveNotification gets triggered that resets the viewcontrollers frame? 有没有人知道在UIApplicationDidBecomeActiveNotification被触发后重置viewcontrollers框架后会调用什么?

我遇到了同样的问题,如果你通过Key Value Observers附加一个观察者,你可以看到在UIApplicationDidBecomeActiveNotification之后调用了一些东西。

In Your application any class can be an "observer" for different notifications. 在您的应用程序中,任何类都可以成为不同通知的“观察者”。 When you create view controller, you can register it as an observer for the UIApplicationDidBecomeActiveNotification and specify which method that you want call when that notification gets sent your your application. 创建视图控制器时,可以将其注册为UIApplicationDidBecomeActiveNotification的观察者,并指定在您的应用程序发送通知时要调用的方法。

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMethod:) name: UIApplicationDidBecomeActiveNotification object:nil];

remove observer in ViewWillDisappear/viewDidDisAppear/Dealloc as per your need: 根据您的需要删除ViewWillDisappear / viewDidDisAppear / Dealloc中的观察者:

[[NSNotificationCenter defaultCenter] removeObserver:self];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iPhone:在viewWillAppear之前的viewDidLoad之后调用什么? - iPhone: What gets called after viewDidLoad before viewWillAppear? 是否随时调用UIApplicationDidBecomeActiveNotification? - UIApplicationDidBecomeActiveNotification is called any time? 在4.3中调用applicationWillTerminate - applicationWillTerminate gets called in 4.3 CellForRowAtIndexPath被意外调用 - CellForRowAtIndexPath gets called unexpectedly beginBackgroundTaskWithExpirationHandler 永远不会被调用 - beginBackgroundTaskWithExpirationHandler never gets called 从另一个应用程序调用 iOS Safari 时会触发什么 Javascript 事件 - What Javascript event gets fired when iOS Safari gets called from another app 从NIB实例化时调用UIView的方法是什么? - What method of UIView gets called when instantiated from a NIB? 对于某些iPhone,仅在打开屏幕后才调用信标didenterregion - For some iPhones the beacon didenterregion gets only called after screen is turned on 在[facebook授权:权限]之后,Facebook fbDidLogin被多次调用 - Facebook fbDidLogin gets called multiple times after [facebook authorize:permissions] 是否可以在touchesBegan之后立即拉出触摸点:被调用? - Is it possible to pull for touch points immediately after touchesBegan: gets called?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM