Several UIAction tables open at the same time

I have a question about UIActionSheet on iPad.

When I present an action table from presentFromBarButtonItem:animated:and present another after that (by clicking on another UIBarButtonItem on the same UIToolbar), the original UIActionSheet file remains open.

It doesn’t look very good.

I tried iterating through self.view.subviewsand dropped the view to the UIActionSheet and called its corresponding method dismissWithClickedButtonIndex:animated:, however it does not work.

For instance:

- (void)pressBarButtonItem {
    for (UIView *view in self.view.subviews) {
        [(UIActionSheet *)view dismissWithClickedButtonIndex:-1 animated:YES];
    }
}

Any help was appreciated.

+3
source share
2 answers

I think you mean showFromBarButtonItem:animated:instead presentFromBarButtonItem:animated:?

iPad , .

. showFromBarButtonItem self.itemFooActionSheet = actionSheet;.

, rejectWithClickedButtonIndex itemFooActionSheet. , itemFooActionSheet , .

, , Foo, . , Foo, , self.itemFooActionSheet, , + ( ).

+4

UIBarButtonItems enabled NO, , , :

self.navigationItem.rightBarButtonItem.enabled = NO;

... YES, ( - ).

0

Source: https://habr.com/ru/post/1782077/


All Articles