Reputation: 415
I'm trying to create an UIPickerView in UIAlertView, I wrote the following code
UIAlertView *alert = [[UIAlertView alloc] initWithFrame:CGRectMake(0, 0, 300, 200)];
alert.title = @"Preferences";
alert.message = @"\n\n\n\n\n\n\n";
alert.delegate = self;
[alert addButtonWithTitle:@"Cancel"];
[alert addButtonWithTitle:@"OK"];
UIPickerView *myPickerView = [[UIPickerView alloc] initWithFrame:CGRectZero];
myPickerView.delegate = self;
myPickerView.showsSelectionIndicator = YES;
myPickerView.autoresizingMask = UIAlertViewStyleDefault;
myPickerView.frame = CGRectMake(10, 40, 250, 150);
[alert addSubview:myPickerView];
[alert show];
but when run, the pickerView size is not fit the alert view, it looks as shown in the image.
how can I solve this issue? Thanks in advance.
I solved it, I discovered that I have the following code
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
int sectionWidth = 300;
return sectionWidth;
}
when I removed this, It fixed. :) thanks for everyone tried to help me, and I'm very sorry for my mistake. :$
Upvotes: 1
Views: 1431
Reputation: 5060
Change the Width in xib.For this you need to open the Xib in XML form and find that PickerView and change the width and save,run.Hope This Will Work!!
Upvotes: 0
Reputation: 1679
I had a requirement similar to this. But I couldn't succeed it using 'UIPickerView'. So I moved to 'AFPickerView'. May be that would help you too!!
Upvotes: 1
Reputation: 139
I'm seriously questioning this style. Besides, I dont think you can actually change the size of an UIAlertView. I suggest you perform a modal segue with form sheet presentation to show a UIView wich you placed an UIPickerview on with some buttons to confirm or cancel. You can do this using a StoryBoard or program it manually.
Upvotes: 0
Reputation: 1
You can not resize pickerView height only change width and x and y coordinates Or you have to make alertview big eno
Upvotes: 0