开发者

UIPickerView in an actionsheet in landscape

I display a picker view in an actionsheet in my iPhone app; that is, I have a button in a view which triggers an actionsheet that holds a picker view. It works great, except when the user rotates the device. When the user displays the view in landscape mode and then touches the button for the actionsheet, the pickerview does appear, but it looks jacked up. On the other hand, when the user loads the view in portrait mode and then touches the button which prompts the a开发者_JS百科ctionsheet, it looks ok. Any thoughts as to what might be going on here?

UIPickerView in an actionsheet in landscape

UIPickerView in an actionsheet in landscape


Make sure you configure the bounds of the action sheet and the frame of the pickerview to suit the orientation you're using.

I'm using the following settings for landscape:

[self.sheet setBounds:CGRectMake(0, 0, 480, 400)];
CGRect pickerFrame = CGRectMake(0, 40, 480, 180);
closeButton.frame = CGRectMake(420, 7.0f, 50.0f, 30.0f);

And the following for portrait:

[sheet setBounds:CGRectMake(0, 0, 320, 500)];
CGRect pickerFrame = CGRectMake(0, 40, 0, 0);
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);

Good luck!

//Seto

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜