在ipad中,选择标记显示在窗口小部件滚轮中。我想使用普通的select标签并在ios中禁用该功能。请查看此链接以更好地理解我的意思:http://alvinalexander.com/iphone/iphone-ipad-html-select-widget-wheel。
答案 0 :(得分: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];
}