UIActionSheet with non dismissing buttons - iphone

I want to rise a UIActionSheet with one normal "Cancel" button as usual, but with a few non-dismissing buttons, as all buttons on action sheet dismiss the sheet when touched down.
I've tried to add UIButtons using addSubView but Im having a tough time dealing with the ActionSheet size.
Any advice?
TY!

I don't believe you can do this with a UIActionSheet.
You could however create your own view that looks like an ActionSheet and add it to the View in question. Add some core animation to make it slide up and down and viola! You'd have a custom UIActionSheet!

Related

Can I pull up a UIActionSheet with a touchable background?

I have a UIPickerView on a UIActionSheet. Right now the UIActionSheet makes the view behind the UIActionSheet not touchable. Is there a way that I can make it touchable? Or is that just how a UIActionSheet works?
I don't believe it is possible to make the view behind the UIActionSheet touchable without dismissing it first. They're meant to be modal, i.e. require the user's attention before being dismissed.
From UIActionSheet class reference (emphasis mine):
For applications running on iPhone and iPod touch devices, the action sheet typically slides up from the bottom of the window that owns the view. For applications running on iPad devices, the action sheet is typically displayed in a popover that is anchored to the starting view in an appropriate way. Taps outside of the popover automatically dismiss the action sheet, as do taps within any custom buttons. You can also dismiss it programmatically.
I suppose a way around this could be that you just create your own view that displays similarly. For example, create a UIView that you can animate the same (slide up) when a button is pressed. This UIView can contain your UIPickerView and whatever else you need (probably a cancel button to dismiss it).
Hope this helps, good luck!

Creating a View popup over another ViewController on iPhone

I am trying to make some kind of popup view when a button i pressed on the iPhone. And it would be nice if I could manage that popup view with a ViewController. I have found out that the UIPopoverController could have been the solution, but it seems that it only works on the iPad...
But anyway, are there any similar solutions for the iPhone?
I am using storyboard
Check out these repos on Github:
https://github.com/werner77/WEPopover
https://github.com/50pixels/FPPopover
Create a separate view controller and resize its xib file and make it look like a popup.
Then ADD this view controller as a subview, and also add it as childController too.
[self addChildViewController:self.popOverViewController];
[self.view addSubview:self.popOverViewController.view];
Now Make it hidden initially.
self.popOverViewController.view.hidden = YES;
If a user taps on Button then using fade in & Fade out animation you can hide/unhide it.
I can tell you how to fade in and fade out if you want to know it further, I hope you can do it easily.
In interface builder make a UIView size of the screen and then make another in that Uiview with the style, size and the such for your pop over. Make its class, hook everything together.
CustomPopUpView *view = [[CustomPopUpView alloc] initWithFrame.....]
Add this all to your UIViewController with
[self.view addsubview:view]
Then attach a tapGestureRecognizer to the back view that animates the whole view off screen when tapped. So now if they click off your pop over view it close it will animates it off screen.
Hope this makes sense.
BooRanger

Hiding ToolBar in a UIViewController

I have a UIViewCOntroller, and in that i have a button and a text field. When i click the button i display a UIToolBar.
Now when i click anything in the background (the textfield or the blank view) i need this UIToolBar to disappear. How can i do this programmatically ?
I know how to add a UIToolBar but all what i need to know is to hide it when the user clicks on the background.
I don't think i will have to paste any code here or show my workings so far, coz i have no clue how to get this done
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setToolbarHidden:YES animated:YES];
}
May be it can help you....
You will need to capture a touch on the views outside of your toolbar to achieve this. If you have a custom UIView base class that all of your other views use, you might start there. Otherwise, perhaps use some sort of toggle to show/hide your toolbar instead in your UIViewController.
The easiest way to do this is to make a single large clear button that is behind the first button but above everything else. Normally have it set to hidden but when you show the toolbar unhide the button as well. When the button is clicked have it hide the toolbar and its self. No need to do anything crazy like sub classes.

Touch above the uiTabBar

I have an app that has an UITabBarController.
I've noticed that there are like 15 pixels above the tab bar that will push the button under it. And there are like 10 more pixels that don't do anything.
The problem is that i have some button in the view that are quite close near the bar bar and when i try to touch them, the tabbar buttons get pushed.
It seems like this is standard behavior for standard UI elements. I've noticed that the buttons from the navigation bar have the same efect
Regards,
George
Some times I get this problem when i am using action sheets top of the tab bar. The button is in top of the tab bar is hard to click. Only part of the button is clicking. So what I am doing there is adding the action sheet from the parentview controller.
[actionSheet showInView:self.parentViewController.tabBarController.view];
After doing this button is working perfectly. I think you can add the button to your app like this too. Hope this will help. Thank you.

programmatically ActionSheet's Buttons

I need some guidance for following :
I have an ActionSheet. When it appears it shows my custom view with two buttons.
The View is called from another (.h/.m)file using xib.
How can I set cancel event on one of the button. Buttons are added into view not in ActionSheet.
OR How can I put buttons on ActionSheet programmatically ?
Thanks...
Here is the link to your answer.
Also you can refere the Class Reference for UIActionsheet to get all the solutions related to action sheet.
You can make your own action sheet. For this you have to make a view controller and you can use it as action sheet by using
[self presentModalViewController:YourViewController animated:YES];
And on cancel btn action you can do
[self dismissModalViewControllerAnimated:YES];
Hope it will work for you.
You have to remove that view from superview when user tap on cancel button.