开发者

Updating UIMenuController on the fly

My application has the ability to pop up a menu. When the "Select All" button is pressed, I want to enable the "Delete" button. However I haven't been able to get this working.

Here is a sample project illustrating the issue. Run it, then tap the Menu button, press Select All. The Delete button should appear immediately, but it 开发者_Go百科only appears when you hide the menu and then show it again. How can I fix this?


The following does the trick:

- (void)didHide:(NSNotification *)notif {
    UIMenuController *mc = [UIMenuController sharedMenuController];
    dispatch_async(dispatch_get_global_queue(0,0), ^{
        dispatch_async(dispatch_get_main_queue(), ^{
            [mc update];
            [mc setMenuVisible:YES animated:YES];
        });
    });
}

I've noticed however that it does not work very reliable, for example when setting animated to NO, the menu is not updated on the fly.


This is resolved in iOS 5 (rdar://problem/8819322).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜