I've a simple question on UIActionSheet! how do I set the height of UIActionsheet? I've tried setFrame and setBounds but nothing is working. I'm using following action sheet:
NSString *title = UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation) ? @"\n\n\n\n\n\n\n\n\n" : @"\n\n\n\n\n\n\n\n\n\n\n\n" ;
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:[NSString stringWithFormat:@"%@%@", title, NSLocalizedString(@"", @"")]
delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Button1",@"Button2", nil];
[actionSheet setTag: 1];
//[actionSheet setBounds:CGRectMake(0,0,320,150)];
//[actionSheet showFromRect:CGRectMake(0,0,100,50) inView: self.parentViewController.tabBarController.view animated:YES];
// [actionSheet setFrame:CGRectMake(0, 30, 320, 30)];
actionSheet.actionSheetStyle = UIActionSheetStyleAutomatic;
[actionSheet showInView:self.parentViewController.tabBarController.view];
actionSheet = nil;
my problem here is action sheet height is equal to current view's height. I would like to auto adjust the height based on the contents of the UIActionSheet.
Thanks in advance,
UIActionSheet
's default behavior is to auto-adjust to its content size. You shouldn't ever set the frame
directly.
You're seeing the action sheet take up so much room because you're inserting a bunch of newline characters into the title, forcing the title label to take up more vertical space than it should. If you don't want the action sheet to be that tall, don't hack the title like that.