问题
I have my pickerview set up and everything works fine, but right now I have that big pickerview taking up a lot of space in Interface Builder. It's annoying having to move it around when working in Interface Builder. How do I set the pickerview and it's location without using IB?
回答1:
Try this:
// Add the picker
UIDatePicker *pickerView = [[UIDatePicker alloc] initWithFrame:CGRectMake(0,100,0,0)];
[pickerView setDatePickerMode:UIDatePickerModeTime];
[self.view addSubview:pickerView];
[self.view showInView:self.view];
[self.view setBounds:CGRectMake(0,0,320, 500)];
[pickerView release];
The above code is for UIDatePicker, you may similarly implement it for other types of uipickers as well.
来源:https://stackoverflow.com/questions/2465371/uipickerview-without-ib