1

在 ipad 中,选择标签显示在小部件轮中的弹出窗口中。我想在 ios 中使用普通的选择标签 abd 禁用该功能。检查此链接以更好地理解我的意思:http ://alvinalexander.com/iphone/iphone-ipad-html-select-widget-wheel 。

4

1 回答 1

0

看到下面的代码希望它会帮助你...享受代码

   -(void)showPicker{

    UIToolbar *toolPicker = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
    toolPicker.barStyle = UIBarStyleDefault;

    UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleBordered target:self action:@selector(hidePicker)];

    [toolPicker setItems:[NSArray arrayWithObjects:cancelButton,  nil]];

    pickerCategory = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0, 44.0, 0.0, 0.0)];
    pickerCategory.delegate=self;
    pickerCategory.dataSource=self;
    pickerCategory.showsSelectionIndicator = YES;
    txtCategory.inputView=pickerCategory;
    [pickerCategory addSubview:toolPicker];

    CGRect thePickerFrame = pickerCategory.frame;
    thePickerFrame.origin.y = toolPicker.frame.size.height;
    [pickerCategory setFrame:thePickerFrame];

    UIView *view = [[UIView alloc] init];
    [view addSubview:pickerCategory];
     [view addSubview:toolPicker];

    UIViewController *vc = [[UIViewController alloc] init];
    [vc setView:view];
    [vc setContentSizeForViewInPopover:CGSizeMake(320, 260)];

    popover = [[UIPopoverController alloc] initWithContentViewController:vc];


    [popover presentPopoverFromRect:txtCategory.bounds inView:txtCategory permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];


}
-(IBAction)hidePicker{
    [popover dismissPopoverAnimated:YES];
}
于 2012-11-24T08:03:41.880 回答