简体   繁体   English

带有 UIPickerView 和完成、下一个、上一个按钮的 UIActionSheet

[英]UIActionSheet with UIPickerView and Done, Next, Previous buttons

i am trying to implement an action sheet that contains a picker view and a segmented control bar with a previous button, next button and done button like the image as follows http://imgur.com/8wVMy .我正在尝试实现一个包含选择器视图和分段控制栏的操作表,其中包含上一个按钮、下一个按钮和完成按钮,如下图所示http://imgur.com/8wVMy I currently am able to make it look like this http://imgur.com/AXn6H .我目前能够使它看起来像这样http://imgur.com/AXn6H I was wondering if someone could help me get the picker view to sit on the bottom and just make it look a little better.我想知道是否有人可以帮助我将选择器视图放在底部并让它看起来更好一点。 Thanks for any help.谢谢你的帮助。

Unless you're targeting very old versions of iOS (ie versions earlier than 3.2), the best way to do it is to take a completely different approach.除非您的目标是非常旧的 iOS 版本(即早于 3.2 的版本),否则最好的方法是采用完全不同的方法。

As of 3.2, any UIResponder (which includes all UIViews) can return a UIView from its inputView property to show that view instead of the keyboard when the view becomes the first responder.从 3.2 开始,任何 UIResponder(包括所有 UIView)都可以从其inputView属性返回 UIView 以在视图成为第一响应者时显示该视图而不是键盘。 This even works for views that normally don't become first responder or don't display the keyboard at all.这甚至适用于通常不会成为第一响应者或根本不显示键盘的视图。 It's simple:这很简单:

  1. Design your popup view, as you would any other view.设计您的弹出视图,就像您设计任何其他视图一样。
  2. Ensure that your widget view returns YES from canBecomeFirstResponder .确保您的小部件视图从canBecomeFirstResponder返回 YES。
  3. Ensure that your widget view returns an instance of your popup view from inputView .确保您的小部件视图从inputView返回弹出视图的实例。

More details are available in the documentation . 文档中提供了更多详细信息。

Also, BTW, if you're on an iPad you should probably use a UIPopoverController to display a UIPickerView instead of either of these methods.另外,顺便说一句,如果您使用的是 iPad,您可能应该使用 UIPopoverController 来显示 UIPickerView 而不是这些方法中的任何一种。 Apple may actually require this if you intend to get your app in the app store.如果您打算在应用商店中获取您的应用,Apple 实际上可能会要求这样做。

The next and previous buttons are actually showing your images to segmentedController Within a toolbar.下一个和上一个按钮实际上是在工具栏中将您的图像显示给分段控制器。 To get it You have to define the segmentedController and UIToolbar on.要得到它你必须定义segmentedController和UIToolbar。 H. Next add the DataSource and UIPickerView Then in the viewDidLoad create objects and define Their properties. H. 接下来添加 DataSource 和 UIPickerView 然后在 viewDidLoad 创建对象并定义它们的属性。 For example:例如:

 if (keyboardToolbar == nil) {
        keyboardToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 44)];
        [keyboardToolbar setBarStyle:UIBarStyleBlackTranslucent];


        segControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Anterior", @"Siguiente", nil]];
        [segControl setSegmentedControlStyle:UISegmentedControlStyleBar];
        [segControl setTintColor:[UIColor blackColor]];
        segControl.frame = CGRectMake(5, 7, 150, 33);
        segControl.momentary = YES;
        [segControl addTarget:self action:@selector(segSelected:) forControlEvents:UIControlEventValueChanged];

        UIBarButtonItem *extraSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];

        UIBarButtonItem *aceptar = [[UIBarButtonItem alloc] initWithTitle:@"Hecho" style:UIBarButtonItemStyleDone target:self action:@selector(cerrarTeclado:)];

        //aceptar.width = 70.0f;

        [keyboardToolbar setItems:[[NSArray alloc] initWithObjects: extraSpace, aceptar, nil]];
        [keyboardToolbar addSubview:segControl];
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将UIPickerView添加到UIActionSheet(底部的按钮) - Adding UIPickerView to UIActionSheet (buttons at the bottom) UIWebView 中的 iPhone 键盘,如何更改下一个/上一个和完成按钮的语言 - iPhone keyboard in UIWebView, how to change the language of next/previous and done buttons 更改iOS虚拟键盘“previous”,“next”,“done”按钮的语言 - Change the language of iOS virtual keyboard “previous”, “next”, “done” buttons 如何在UIActionSheet中添加UIPickerView - how to add UIPickerView in UIActionSheet 将UIPickerView和UIToolBar添加到UIActionSheet时出现问题 - Problems with adding UIPickerView and UIToolBar to UIActionSheet iPhone MPMoviePlayerController上的下一个/上一个按钮 - Next/Previous buttons on iPhone MPMoviePlayerController 在html表单中删除“上一个”,“下一个”和“完成”按钮 - Remove 'previous', 'next' and 'done' button at html form 如何使用Next,Previous和Done Button键盘? - How to get keyboard with Next, Previous and Done Button? 如何使用UITextView显示“上一个/下一个/完成”栏 - How to show the “Previous/Next/Done” bar with a UITextView 如何浏览文本字段(下一步/完成按钮) - How to navigate through textfields (Next / Done Buttons)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM