iOS - How to check if a modal view is present

后端 未结 4 947
傲寒
傲寒 2021-01-30 05:13

Is there a way to check if a modal view is present? I\'d like to run a method only if a modal view is present. Also, if I have multiple modal views, is there a way to check if a

4条回答
  •  萌比男神i
    2021-01-30 05:44

    Are you checking the presence of a modal view controller from the parent view controller? If so, you can just check that view controller's modalViewController property:

    BOOL modalPresent = (self.modalViewController);
    

    If you want to check for a particular modal view controller, you can get the modal view controller's class name like this:

    NSString *modalClassName = NSStringFromClass([self.modalViewController class]);
    

提交回复
热议问题