Is there a way to detect what UIView is currently visible?

后端 未结 2 1690
悲&欢浪女
悲&欢浪女 2020-12-15 01:58

I have a class that communicates with a web service and is used throughout the app. What I am looking for is a way to display an Error message in a UIActionSheet on top of w

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-15 02:35

    What you want to do is find the first responder of the key window I would think. You can do that like this:

    UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
    UIView   *firstResponder = [keyWindow performSelector:@selector(firstResponder)];
    

    That should give you the view to use in your call to the UIActionSheet.

提交回复
热议问题