[英]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:
这很简单:
canBecomeFirstResponder
.canBecomeFirstResponder
返回 YES。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.