选择器视图的替代方案

3
有没有其他用于选择变量的UI对象,而不是选择器视图?
我非常新手iOS开发,我想创建一个用户填写表单的应用程序。
要在少量变量中进行选择,例如“男”或“女”,以及“大学”,“高中”或“孩子”,我希望使用下拉列表,但我能找到的唯一接近的是选择器视图。问题是选择器视图太大了,当只有2或3个变量时看起来不必要。
2个回答

5
在iOS中处理这个问题的常见方法是将UITableViewController推入UINavigationController堆栈,每个选项占据一行。使用委托方法来传递所选选项。
如果您想显示已选择的选项,请设置cell.accessoryType = UITableViewCellAccessoryCheckmark

1
我会使用 UISegmentedControl。

http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UISegmentedControl_Class/Reference/UISegmentedControl.html

[NSArray arrayWithObjects: @"Male", @"Female", nil];
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:itemArray];
segmentedControl.frame = CGRectMake(35, 200, 250, 50);
segmentedControl.segmentedControlStyle = UISegmentedControlStylePlain;
segmentedControl.selectedSegmentIndex = 1;

// replace self.view with whatever your view is.. alternatively you can also add a UISegmentedControl with Interface Builder in your XIB file.
[self.view addSubview:segmentedControl];

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接