0
votes

I want to show a UIActionSheet in the middle of the screen.I tried with the following code

UIView *placeholderview=[[UIView alloc]initWithFrame:CGRectMake(0, 310, 320, 100)];
[self.view addSubview:placeholderview];
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Open File",@"Save FIle",@"New File",@"Export Image",nil];
[actionSheet showFromRect:CGRectMake(0,0, 320, 10) inView:placeholderview animated:YES];
[actionSheet release];

I get the result as desired but i can click only cancel button, and the half of export image button.I don't know where i am going wrong.Kindly please any body help me.What should i do to make it working.enter image description here

2
what is the exactly problem you are facing,plz elaborate your question is not understandableGypsa
is possibly only the part inside your placeholderview clickable? have you tried to expand it?Axel
I dont think apple will be happy with this..:(Krishnabhadra

2 Answers

4
votes

UIActionSheet is designed to be presented from the bottom of the screen.

It provides methods for presenting from a toolbar or tab bar in cases where those UI elements may cause obstruction.

Why are you wanting to show the action sheet in the middle of the screen. I wouldn't recommend this because it looks wrong, and isn't the designed behaviour of the control.

The method you are currently using is for iPad - it shouldn't be used on iPhone, as it causes undefined behaviour (as you are experiencing).

3
votes

UIActionSheet's showFromRect:inView:animated: method is only supposed to be used on iPad. Its behavior on iPhone is undefined.