开发者

UIPickerView frozen when starts

I've got a strange problem, I managed to blend UIActionSheet together with UIPickerView and invoke them both from UITextField, but the problem is that in order to use UIPickerView I have to click/tap on "Done" button first. Then, the picker view becomes usable. But, initi开发者_运维问答ally, when the picker view appears, it is frozen and unusable - the wheel doesn't move. Only after I tap on "Done", the background gets more transparent, I can see in the background the other UITextFields that I added to the scrollView, and I can move the wheel at that point. So to move the wheel I need to first tap on either "Cancel" or "Done", it's frozen when it appears at first.

Here's my code (some of it is from researching)

 
myPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0,185,0,0)];
myPicker.delegate = self;
myPicker.showsSelectionIndicator = YES;
UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"Title"    delegate:self cancelButtonTitle:@"Done" destructiveButtonTitle:@"Cancel" otherButtonTitles:nil];
[menu addSubview:myPicker];
[menu showInView:self.view];
[menu setBounds:CGRectMake(0,0,320, 700)];
[myPicker release];
[menu release];

The solution I thought of is to automatically make "Done" be tapped first time so user doesn't have to tap on "Done" to use the wheel and then tap on "Done" again when selection from the wheel is chosen. But I'm not sure that's the right approach.

I also tried to make it:


 [menu showInView:scrollView];

But the result was the same - wheel doesn't move.

Anybody knows how I should solve this?

Thank you, Victor.


There's no way your app will be approved if you misuse UIActionSheet in this way, and it's not designed to work in this way, and (as you've found and as I've found when I once tried it) it does funny things when you try to use it in this way. So it's not work the effort to get it working.

You should use a standard full screen view containing your picker and then use presentModalController:. You could alternatively manually add the picker as a subview of your main view, if the intention is to have it as an overlay.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜