HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 在iPad中的UIActionSheet中添加UIPickerView大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个UIPickerView,需要让它显示在iPad的UIActionSheet中(它在iPhone中非常直接,而不是在iPad中).

当我点击时,我在视图上有一个按钮我执行以下代码

- (IBACtion) buttonPressed:(id)sender
{
    NSLog(@"I am pressed");

    UIPickerView* picker = [[UIPickerView alloc] initWithFrame:CGRectMake(100,200,500,500)];
    picker.delegate = self;
    picker.datasource = self;
    picker.showsSelectionInDicator = YES;
    [self.view addSubview:picker];    
}

// PickerView委托和数据源函数

// returns the number of 'columns' to display.
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}

// returns the # of rows in each component..
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    return 5;
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    return @"One";
}

但是当更改上面的代码以在ActionSheet中添加PickerView时,它只显示ActionSheet的标题,但里面没有PickerView!

修改后的代码如下:

- (IBACtion) buttonPressed:(id)sender
{
    NSLog(@"I am pressed");

    UIActionSheet* actionSheet = [[UIActionSheet alloc] initWithtitle:@"My PickerView"
                                              delegate:nil
                                     cancelButtontitle:nil
                                destructiveButtontitle:nil
                                     otherButtontitles:nil];

    UIPickerView* picker = [[UIPickerView alloc] initWithFrame:CGRectMake(100,500)];
    picker.delegate = self;
    picker.datasource = self;
    picker.showsSelectionInDicator = YES;

    [actionSheet addSubview:picker];
    [actionSheet showFromRect:CGRectMake(0,320,469) inView:self.view animated:NO];

}

解决方法

我卡住了,我会在内部使用带UITableViewController的UIPopoverController! .. 不管怎么说,还是要谢谢你!

大佬总结

以上是大佬教程为你收集整理的ios – 在iPad中的UIActionSheet中添加UIPickerView全部内容,希望文章能够帮你解决ios – 在iPad中的UIActionSheet中添加UIPickerView所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。