简体   繁体   English

如何确定哪个视图处于活动状态?

[英]How can I determine which view is active?

I have a viewController, with 5 views and I want to initialize some stuff depending on the view so in the viewDidLoad() , I want to do a : 我有一个viewController,有5个视图,我想根据视图初始化一些东西,所以在viewDidLoad() ,我想做一个:

if self.view == view1 { // Stuff here }
if self.view == view2 do { // Stuff here }

But it's doesn't work. 但这是行不通的。 So how can I detect the active view? 那么如何检测活动视图?

if([self.view1 isFirstResponder]){
//Do some nice stuff
}

You can do it with isFirstResponder 您可以使用isFirstResponder

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

相关问题 如何确定哪个视图控制器当前处于活动状态/显示视图的视图控制器? - How to determine which view controller is currently active/the one displaying a view? 如何检查并确定情节提要中当前显示的视图控制器? - How can I check and determine which view controller in storyboard is currently showing? 如何确定调用视图 controller? - How can I determine the calling view controller? 我怎么知道哪个ViewController是活动的? - How can I know which ViewController is active? 如何确定哪个文本字段是活跃的 - How to determine which textfield is active swift 如何在TabbarController中确定当前的活动视图 - How to determine the current active view in tabbarcontroller 如何获得确定要转到哪个视图控制器的按钮? - How can I get a button to determine which viewcontroller to go to? 如何确定哪个NSArray导致了XCode中的异常 - How can I determine which NSArray has caused the Exception in XCode 如何确定哪个 UIControlEvents 类型导致了 UIEvent? - How can I determine which UIControlEvents type caused a UIEvent? SwiftUI:如何确定视图是在 NavigationView、Sheet 中呈现还是在根目录中? - SwiftUI: How can I determine if a view is presented in a NavigationView, Sheet, or is the root?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM