2017-08-25 116 views
3

BugFender有一個叫做UI Logging功能。例如,它的功能是在視圖控制器進入屏幕並記錄信息時進行監視。另一個例子是當一個按鈕被觸摸時:iOS版 - 登錄UI事件視圖控制器等出現/消失

Fri Aug 25 2017 08:24:30 GMT+0200 (CEST) UI Front-most view controller: SettingsViewController (title: "Settings") 
Fri Aug 25 2017 08:24:35 GMT+0200 (CEST) Interaction Action [UIBarButtonItem _sendAction:withEvent:] by sender UINavigationButton (title:"Log Out") 
Fri Aug 25 2017 08:24:35 GMT+0200 (CEST) Interaction Action [SettingsViewController logOut:] by sender UIBarButtonItem (title:"Log Out") 
Fri Aug 25 2017 08:24:36 GMT+0200 (CEST) UI Front-most view controller: UIAlertController 

我想實現具有相同的功能。

如何遵守所有的視圖控制器在我的應用程序的出現/消失?

到目前爲止,我發現,我所觀察到UINavigationControllerDidShowViewControllerNotification通知。然而,這將無法登錄UITabBarViewController變化時,或者當一個視圖控制器模態呈現不被包裹在一個UINavigationController。

回答

0

其中一種方法是添加一個基類(比方說BaseViewController)並覆蓋基類的viewWillAppearviewWillDisappear方法來觀察更改。 所有其他viewControllers將這個BaseViewController的子類。

相關問題