0
votes

I have a UIToolbar adding to the view, and the toolbar has several UIBarButtonItem. And one of the buttons will call out the UIDocumentInteractionController Open In menu. In iPhone, the Open In menu works like a UIActionSheet, it will show up from the bottom of the screen and disable all other buttons except itself (and other part of screen will be masked by a light gray shadow, u know what I mean).

My problem is that, when the Open In menu shows up, all the buttons in the UIToolBar disappear, kind like "automatically hide" by iOS. After dismissing the Open In menu, the buttons will come back. All I want is keeping the buttons visible when Open In menu is opened.

This problem only appears in iOS6 (and iPhone of course), since in iOS5, the Open In menu has a different style. I'm not very sure if this behavior can be changed. However, the Adobe PDF reader app seems doing the same thing like mine, but the toolbar items never disappear.

The code I use to call out the Open In menu is like this:

[documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.topBar animated:YES]

the self.topBar is the toolbar I mentioned before, I also tried self.view, self.view.window etc, but none of them worked.

Did I miss sth? Or is there some workaround?

Adding more code as required:

The UIToolbar is added in the XIB file, and I customize one UIBarbuttonItem with a UIButton like this:

UIButton *button = [UIButton  buttonWithType:UIButtonTypeCustom];
[button setImage:image forState:UIControlStateNormal];
button.frame = CGRectMake(0, 0, image.size.width, image.size.height);
[button addTarget:self action:@selector(doSth) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *tItem = [[UIBarButtonItem alloc] initWithCustomView:button];

And then I add the tItem to the items array of the UIToolbar:

NSArray *items = [NSArray arrayWithObject:tItem];
topBar.items = items;

the "doSth" method only do one thing, just init a UIDocumentInteractionController and show the Open In menu:

UIDocumentInteractionController documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
[documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.topBar animated:YES];

Of course there're more bar button items in the toolbar. So, when the Open In menu is shown, all the buttons are "hidden". I think Apple may do this by design, but I'm wondering is there some workaround to change this behavior.

1
can u provide some of ur code ... itl b easier to analyse ...IronManGill
looks like a duplicate of stackoverflow.com/questions/13031608/…, try my solution therexu huanze

1 Answers

0
votes

The secret here is to use a UINavigationBar instead of a UIToolbar. Officially, UIToolbars should be used at the bottom of the screen and UINavigationBars at the top. (However, this may have not been possible previously because it wasn't until iOS5 that a UINavigationBar could have more than a single item at each end.)

This does appear to be "as-designed" by Apple. For an example of where this functionality may be helpful, look at the bottom toolbar while viewing a file in the Dropbox app. (If they did not hide the items, they would land directly at the seam of the Cancel button.)