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).
精彩评论