如何向 UIPickerView 控件添加自定义工具栏?

发布于 2024-10-05 22:18:18 字数 88 浏览 0 评论 0原文

我想在 UIPickerView 控件的顶部添加一个自定义工具栏。我在键盘上执行此操作,但无法使用 UIPickerView 执行此操作。

尼尚特

I want to add a custom toolbar at the top of the UIPickerView control. I did this on Keyboard but not able to do with UIPickerView.

Nishant

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

瞄了个咪的 2024-10-12 22:18:18

通过 IBoutlet 创建一个工具栏,并将其 y 坐标设置为 100 或大于视图高度。然后在特定的操作中相应地改变 y 坐标。这是通过动画完成的。

您还可以将其与键盘一起使用。

通过使用
-(void)keyboardWillShow:(NSNotification *) 注意

-(void)keyboardWillHide:(NSNotification *)注意

make a toolBar by IBoutlet and set its y coordinate to 100 or more than view's height. then in particular action change y coordinate accordingly. this is done via animation.

You also use this with keyboard .

by using
-(void) keyboardWillShow:(NSNotification *) note
and
-(void) keyboardWillHide:(NSNotification *) note

东北女汉子 2024-10-12 22:18:18
 UIToolBar *toolBar= [[UIToolbar alloc] initWithFrame:CGRectMake(0,0,320,44)];
        [toolBar setBarStyle:UIBarStyleBlackOpaque];
        UIBarButtonItem *barButtonDone = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleBordered target:self action:@selector(doneBtnTapped:)];

        toolBar.items = [[NSArray alloc] initWithObjects:barButtonDone,nil];
        barButtonDone.tintColor=[UIColor blackColor];
        [popoverView addSubview:toolBar];

        [popoverView addSubview:pickerView];
 UIToolBar *toolBar= [[UIToolbar alloc] initWithFrame:CGRectMake(0,0,320,44)];
        [toolBar setBarStyle:UIBarStyleBlackOpaque];
        UIBarButtonItem *barButtonDone = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleBordered target:self action:@selector(doneBtnTapped:)];

        toolBar.items = [[NSArray alloc] initWithObjects:barButtonDone,nil];
        barButtonDone.tintColor=[UIColor blackColor];
        [popoverView addSubview:toolBar];

        [popoverView addSubview:pickerView];
云仙小弟 2024-10-12 22:18:18

我创建了一个自定义视图,并在其上添加了一个完成按钮以及选择器视图。

谢谢

I created a custom view and added a done button on that along with picker view.

Thanks

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文