没有IB的UIPickerView? [英] UIPickerView without IB?

查看:38
本文介绍了没有IB的UIPickerView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置好pickerview,并且一切正常,但是现在我拥有很大的pickerview,在Interface Builder中占用了大量空间.在Interface Builder中工作时必须四处移动,这很烦人.如何在不使用IB的情况下设置pickerview及其位置?

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?

推荐答案

尝试一下:

// 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];

上面的代码是针对UIDatePicker的,您也可以类似地将其实现为其他类型的uipicker.

The above code is for UIDatePicker, you may similarly implement it for other types of uipickers as well.

这篇关于没有IB的UIPickerView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆