UIPickerView without IB?

大城市里の小女人 提交于 2019-12-12 18:18:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!