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.
Related
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
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.
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!
I open a UIActionSheet with [actionSheet openInView:view] ... and it opens in the iPhone simulator. And you can't click on it.
Any ideas?
There is one particular issue with action sheets where the cancel button is not touchable when you present a UIActionSheet from a view inside a tab bar controller. To work around this you should present the action sheet from the tab bar controller's view:
[actionSheet openInView:self.tabbarController.view];
You should also check if your view (from which you are showing the actionsheet) is touchable or not means if the view's userinteraction is not disabled. If this is alright then check for Mike Weller's answer.
Hope this helps,
Thanks,
Madhup
I have added a custom button (subclass UIButton) to my navigation bar but the button does not change states when clicked.
The button is configured correctly as it does work in, for example, a table view.
All advice is welcome.
Have you tried subclassing UIBarButton instead of UIButton?
I got it working. What I forgot to implement was the method to change the button selection states.