[英]UIPickerView without IB?
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. 我已经设置好pickerview,并且一切正常,但是现在我有了很大的pickerview,在Interface Builder中占用了大量空间。 It's annoying having to move it around when working in Interface Builder. 在Interface Builder中工作时必须四处移动很烦人。 How do I set the pickerview and it's location without using IB? 如何在不使用IB的情况下设置pickerview及其位置?
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. 上面的代码是针对UIDatePicker的,您也可以类似地将其实现为其他类型的uipicker。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.