I created a new application using the Split View-based Application template.
I then added an Action Button to the rootViewController navigation controller called actionButton.
When the button is pressed, I display an ActionSheet like this:
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil
otherButtonTitles:#"Admin Functions", #"Refresh Data", nil];
[actionSheet showFromBarButtonItem:actionButton animated:YES];
[actionSheet release];
After I press the button when in landscape mode it displays the action sheet in a popover which is pointing to the button (as I expected it to):
However, in Portrait mode it looks completely different and the menu comes up from the bottom of the rootViewController popover just like it does on the iPhone:
My question is, how do I make the ActionSheet appear at the top while in portrait mode, just like it does when in landscape mode?
Since this is a "utility menu", it isn't really tied directly to the data being displayed so it shouldn't be part of the popover.
This behaviour is by design, if it were a popover in portrait mode you would then have 2 levels of popover.
This is technically possible by implementing your own version of UIPopover or using one someone has already written (WEPopover).
However, this is a poor design choice. You say that the functions aren't related to the data, however one is 'refresh data'. I would replace the action button with a refresh icon such as the one Apple uses in 'Find my Friends':
The other, 'Admin Functions', if not directly related to the data in the list, perhaps needs a new home, maybe with the main view of your app? It's hard to say where is best to put it without knowing more about the structure.
Another possibility is that you could move the action button from right edge of the root view controller's bar to the left edge of the detail view controller's bar.
For example, if the action button were located just to the right of the vertical bar in your first screen shot (meaning it's at the left edge of the detail view controller's bar), then when you rotate to portrait mode it would appear just to the right of the Events button in your second screen shot. You could still call UIActionSheet's showFromBarButtonItem:animated method, which would display your action sheet in popup mode.
There's still the question of whether you really want two popovers on the screen at the same time. But if you do, this is how to do it.
Related
I’m using Xcode 6 on an iPad app targeted to iOS7. It’s a master-detail app with a button on each group header view in the master list. I would like the button to display an ActionSheet. I’m having trouble with the ActionSheet.
In order to get the ActionSheet to appear at all I have to pass it the SplitViewController’s view to display itself on:
UIActionSheet* menu = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:#“Button 1”, #“Button 2“, nil];
UIView* view = [[[self appDelegate] splitViewController] view];
[menu showFromRect:[sender convertRect:[sender bounds] toView:nil] inView:view animated:YES];
Passing any other view (such as the TableView, a group header, or a button) generates an exception telling me that I’m trying to display the ActionSheet from a disconnected view. But displaying the ActionSheet this way allows the master view to maintain precedence in the responder chain (mostly):
If the ActionView displays itself on the left side of the screen it displays under the master view. Only the portion to the right of the master view’s edge is visible.
When the ActionSheet is displayed, if I tap one of its buttons the master view slides offscreen and the ActionSheet remains, as if I had not tapped it. Once the master view is gone, tapping an ActionSheet button calls that button’s method.
When the ActionSheet is displayed, if I tap a cell in the master view nothing happens.
When the ActionSheet is displayed, if I tap the detail view, the master view slides offscreen, leaving the ActionSheet displayed.
I’ve read several SO posts on disconnected views and ActionSheets. The table view’s window property is defined as the app’s window, so I think it’s in the view heirarchy. I haven’t found a property in the table view or its controller hierarchy that can cause the table view to become “connected”.
It just seems that if I could find the proper view to pass to the ActionSheet it would correct ActionSheet's behavior.
Is there a solution?
I have one actionSheet and after clicking on button of this another actionSheet is displayed. This is working fine in iPhone but in iPad second actionSheet does not appear after clicking on button of 1st actionSheet.
First of all, UIActionSheet existed before UIPopoverController and UIPopoverController isn't available on iPhone, so it's useful for backwards compatibility and universal apps.
Also, a UIActionSheet isn't necessarily presented in a popover, specifically, if you show it from a UIBarButtonItem or UIToolbar that is already inside a popover. It is then presented in a similar fashion as on the iPhone (sliding in from the bottom of the view controller). According to the HIG, you must not present multiple popovers at the same time (I once had an app rejected for that), so in cases where a view controller may be inside a popover (like in a standard split view app), you may want to use action sheets, if possible. Of course there are a lot of cases where you can't replace a popover with an action sheet, because an action sheet only shows a list of buttons and a title, whereas a popover can display any view controller.
I think that the animated parameter only has an effect when an action sheet is presented in the "classic" (as on iPhone) way.
.I think the issue is you are trying to present second action sheet before first one is dismissed.
In method
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
Check if the action sheet dismissed is first one and then present second one via
- (void)showFromRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animated
You can use tag property to differentiate between the two action sheets.
i am making one iOS tabbar application in that i have put 4 different tabs and whenever i click on 1 st tab and load another view after clicking of the first tab. After that when i press back button then tabbar is not displaying .So that i want hint that how can i show that
back the tabbar when we move from one tab from another and yes how i can use consistent the tabbar in whole application can you just guys help me on this i am new to iOS development.
here i am put the screen shot ...
here first screen is this one..
when i tap the video button that are first in the view then another window open
which are as under and see the tabbar is not there...
when in video controller there is tabbar is there but i drag and connect to that then tabbar is disabled
Looking at your screen snapshots, do I correctly assume you're attempting to transition to the "Videos" scene by touching the big "Videos" button in the center of the "Home" scene (rather than touching the tab bar button at the bottom of the screen, which I assume works fine)? If that's the case, you need to have your button tell the view controller's tab bar controller that you want to change the index of the tab bar, and it takes care of it for you. You cannot do the transition using a segue (or at least not without a custom segue, which is even more complicated than the procedure I outline below). If you're changing the view some other way (e.g. using a standard segue or using presentViewController, pushViewController programmatically, etc.), your tab bar can disappear on you.
You later said:
when in video controller there is tabbar is there but i drag and connect to that then tabbar is disabled
Yes, that's true. You cannot use a segue from one of your big buttons to one of the tabs in your tab bar. (Or technically, if you wanted to use a segue, it would be a custom segue which would do something very much like my below code, though perhaps a tad more complicated.) So, rather than using a segue for your big button, you need to write an IBAction (connected to the big Videos button on the Home scene), that tells the tab bar to change its selection:
- (IBAction)clickedVideosButton:(id)sender
{
[self.tabBarController setSelectedIndex:1];
}
A couple of comments:
My answer was predicated on the assumption that your tab bar works as expected when you tap on the buttons of the tab bar, itself. If you tap the buttons at the bottom of the screen, do you transition to your other views correctly and preserve the tab bar? If so, my answer above should solve your issues in getting the big buttons to work. If not, though, then the problem rests elsewhere and you need to show us your code that might account for that (either you're something non-standard in the UITabBarControllerDelegate methods, or your viewDidLoad of the view is doing something nonstandard).
If I understand your user interface design right, you have the tab bar at the bottom as well as the big buttons in the middle, which presumably do the same thing. That is, no offense, a curious user interface design (duplicative buttons, requiring extra tap on a button, etc.). You might want to choose to either use either big buttons (in which you can retire the tab bar, eliminate the IBAction code I've provided above, and just use a nice simple navigation controller and push segues, for example), or just use the tab bar (and lose the home screen, lose the big buttons, etc.).
You also made reference to "press back button", and I don't see any "back" button on any of your screen snapshots. Do I infer that you have a navigation controller and you're doing a pushViewController or push segue somewhere? If you're doing something with back buttons, you might need to clarify your question further.
I have two xibs, one is my title screen with buttons, the other is a more specific window that should come up when one of the buttons is pressed.
This isn't switching the whole screen, just a popup window, where clicking outside of the bounds of that window will make it disappear leaving only my title screen remaining as it was visible behind this popup view. This is similar to my understanding of "modal views".
Anyway I do not quite get how to connect it to the button on my title screen. I have the views made in IB ready to go. I'm not sure if I have declared all objects to satisfaction yet.
From what I understand I think I need a UIViewController or something, but its all a pretty thick fog of information right now
insight appreciated, or links to proper noob sources would be helpful
Does your title screen have a view controller (or is your app delegate the main controller object)? You will want to add an IBAction to that object, connect the button to it, and then present your other view controller modally (or in a popover) from there.
A popover will appear in a small window with an arrow, and tapping outside will close it. A modal view controller typically slides up into place, and you have to press a cancel button to close it. This guide explains how to use a popover. Using a modal view controller is simple if you have a view controller: [myViewController presentModalViewController:nextViewController animated:YES].
I am looking for a solution to customize PopoverController view in my iPad app. I need to remove the pointing icon along with the popover view and to make the view to the middle of the App window. It should go back to the button from where it is popped when we click on anywhere other than the popover view. USA TODAY app in iPad included such an option. I am not sure about how did they implemented it.
You would need to create your own custon view and animate your self. There is no Appple provided solution