I've noticed in my app that my cancel button is hard to tap, it seem like the hit area is not in the center.
How do I fix this ?
Heres my code...
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:#""
delegate:dg
cancelButtonTitle:#"Cancel" destructiveButtonTitle:nil
otherButtonTitles: #"Help Pages", #"Tutorial",
#"Feedback / Questions ", #"Facebook Group", #"About", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[actionSheet setTag:CommonUIActionSheetHelp];
[actionSheet showInView:vw];
[actionSheet release];
I think your problem lies in the [actionSheet showInView:vw];, perhaps you are using tabBarController/toolBar in you application(at bottom), this error occurs at that time.
you should use either showFromToolbar or showFromTabBar as per your design. If your design is different then please mention it.(if no tabBar/toolBar there).
Thanks
agree whit Ravin answer and you can try
[actionSheet showInView:[UIApplication sharedApplication].keyWindow];
it can help also
I have similar problem in iOS 8, using UIAlertController with style UIAlertControllerStyleActionSheet.
The problem is that the first tap on the action sheet is ignored.
Turned out it got to do with my text field's keyboard interfering with the touches.
The fix is to dismiss the keyboard first, then present the action sheet.
[textfield resignFirstResponder];
[self presentViewController:alert animated:YES completion:nil];
Related
In iOS 7, I show actionSheet by "showFromRect":
[actionSheet showFromRect:rect inView:view animated:YES];
But in iOS 8, this doesn't work. They they replace the implementation and suggest us using UIAlertController. Then how do I show this actionSheet like a popover?
Using UIAlertController you can access the popoverPresentationController property to set the sourceView (aka inView) and sourceRect (aka fromRect). This gives the same appearance as the previous showFromRect:inView:
UIAlertController *alert = [UIAlertController alertControllerWithTitle:#"Title" message:#"message" preferredStyle:UIAlertControllerStyleActionSheet];
// Set the sourceView.
alert.popoverPresentationController.sourceView = self.mySubView;
// Set the sourceRect.
alert.popoverPresentationController.sourceRect = CGRectMake(50, 50, 10, 10);
// Create and add an Action.
UIAlertAction *anAction = [UIAlertAction actionWithTitle:#"Action Title" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
NSLog(#"Action Pressed");
}];
[alert addAction:anAction];
// Show the Alert.
[self presentViewController:alert animated:YES completion:nil];
I also meet this problem like you, but my case is that I show a UIActionSheet in UIWindow.view on the iPad device, and the UIWindow doesn't set rootViewController.
So, I found, if we show a UIActionSheet in a window whose rootViewController equals to nil, the UIActionSheet could not show out.
My solution is to set
window.rootViewController = [[UIViewController alloc] init];
then,
[actionSheet showFromRect:rect inView:window.rootViewController.view animated:YES].
Hope this will help you!
according to this https://developer.apple.com/library/ios/documentation/Uikit/reference/UIActionSheet_Class/index.html thread
UIActionSheet is deprecated, you should use UIAlertController instead of UIActionSheet.
Thanks.
I found out the point is in iOS 7, you show actionSheet in a new window actually when using "showFromRect: inView:" ;
But in iOS 8 you show the actionSheet just on the view you send in parameters.
So the solution is to send
self.superView
[actionSheet showFromRect:rect inView:[self.superView] animated:YES];
Me and my colleague figured it out by randomly trying.
I am experiencing an odd lag in the animation whenever I display a UIAlertView. The buttons and labels on the alert view are appearing noticeably before the background. It is happening everywhere in the application that I display an alert
The alert in the example above is shown from the action method of the clear button:
-(IBAction)clearButtonTapped:(id)sender {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Clear Outbox" message:#"This will delete everything from your Outbox." delegate:nil cancelButtonTitle:#"Cancel" otherButtonTitles:#"OK",nil];
[alert show];
}
Does anyone know why this is happening / what I can do to stop it?
Set "renders with edge antialiasing" to NO in the info.plist
try this
[yourAlert performSelectorOnMainThread:#selector(show) withObject:nil waitUntilDone:NO];
I am looking to add to my iOS app a control that looks like this menu on the bottom:
Can anybody tell me what control that is? Does not look like Picker View.
That is a UIActionSheet. Official Documentation
It cannot be dragged in from the list of UI elements. It is presented programmatically very similar to a UIAlertView.
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:#"Title"
delegate:self cancelButtonTitle:#"Cancel Button"
destructiveButtonTitle:#"Destructive Button"
otherButtonTitles:#"Other Button 1", #"Other Button 2", nil];
[actionSheet show];
I'm creating an UIActionSheet:
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:#"Choose region/city"
delegate:self
cancelButtonTitle:#"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:nil, nil];
for (Cities *c in self.cities) {
[actionSheet addButtonWithTitle:c.name];
}
actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[actionSheet showInView:self.view];
I'm just setting the cities names as the buttontitle. The Cities array length is 8.
The output is fine, but when I click on the first Button ( this one is called Auckland) it says it is a CancelButton.
The other buttons and the cancelbutton works fine, only the first one not. Both the Auckland button and the CancelButton got a buttonIndex of 0.
Can anyone tell me why this is? And how to fix it?
PS:
If i do cancelButtonTitle:nil, its working fine. But i would like the Cancel button:)
I'm creating an app were users should be able to report posts. I want an actionsheet when the user press the report button.
This is my code:
[self.avatarImageView.profileButton addTarget:self action:#selector(didTapReportButtonAction:) forControlEvents:UIControlEventTouchUpInside];
and here is the didTapReportButtonAction code:
- (void)didTapReportButtonAction:(UIButton *)button {
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:#"Title" delegate:nil cancelButtonTitle:#"Cancel" destructiveButtonTitle:#"Destructive" otherButtonTitles:#"Other1", #"Other2", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
[actionSheet addButtonWithTitle:#"Add"];
[actionSheet showInView:[UIApplication sharedApplication].keyWindow];
}
But when I try to press the report button now, nothing happens.
Can someone help me with this?
Can you try this:
[actionSheet showInView:self.view];
If avatarImageView is an UIImageView, its userinteraction property is false by default.
this means the event won't called.
make sure avatarImageView.userInteraction = YES