我的应用程序要求在操作表中添加以下内容.
- Utoolbar
- Button on Utoolbar
- UIPicker控制
我附上了一张图片,以了解我的需求.
您能解释一下,这是如何实施的吗?
我的应用程序要求在操作表中添加以下内容.
我附上了一张图片,以了解我的需求.
您能解释一下,这是如何实施的吗?
Update for iOS 7个
Apple docs for UIActionSheet:UIActionSheet is not designed to be subclassed, nor should you add views to its hierarchy
我建议不要try 自定义操作表的内容,因为它可能会导致iOS 7中严重的无效上下文错误.我只是花了几个小时来解决这个问题,最终决定采取不同的方法.我将显示操作表的调用替换为包含简单tableview的模态视图控制器.
有很多方法可以实现这一点.以下是我刚刚在当前项目中实现的一种方法.这很好,因为我可以在5到6个不同的屏幕之间重复使用它,所有用户都可以从选项列表中进行 Select .
SimpleTableViewController
.itemSelectedatRow:
和称为类型id<SimpleTableViewControllerDelegate>
的委托的弱属性创建协议SimpleTableViewControllerDelegate
.这就是我们将 Select 传递回父控制器的方式.tableView:didSelectRowAtIndexPath:
中调用itemSelectedatRow:
.这种方法还有一个额外的好处,那就是具有相当高的可重用性.要使用,请在ViewController.h中导入SimpleTableViewController类,符合SimpleTableViewDelegate,并实现itemSelectedAtRow:
方法.然后,要打开该模式,只需实例化一个新的SimpleTableViewController,设置表数据和委托,然后呈现它.
UINavigationController *navigationController = (UINavigationController *)[self.storyboard instantiateViewControllerWithIdentifier:@"SimpleTableVC"];
SimpleTableViewController *tableViewController = (SimpleTableViewController *)[[navigationController viewControllers] objectAtIndex:0];
tableViewController.tableData = self.statesArray;
tableViewController.navigationItem.title = @"States";
tableViewController.delegate = self;
[self presentViewController:navigationController animated:YES completion:nil];
我创建了一个简单的示例和posted it on github.
另见Showing actionsheet causes CGContext invalid context errors.