【发布时间】:2016-12-16 12:40:49
【问题描述】:
我有一个实现自定义类方法的主控制器。现在在主控制器中,我想在需要实现 UITableView 委托方法的警报视图中添加一个表。我想实现类似下面的东西
单击Click Here 按钮后,将显示一个警报视图,其中包含一个显示所有项目的表格。
CustomController 定义如下
@interface CustomController : UIViewController
现在
在 .h 文件中
@interface mainController : CustomController<CustomDelegateMethod>
在 .m 文件中
@interface mainController()
必填
在 .h 文件中
@interface mainController : CustomController<CustomDelegateMethod>
// 我想在上面的行中添加UIViewController<UITableViewDelegate, UITableViewDataSource>。
MainController 中的 AlertView 代码:
UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"List of Items" message:nil delegate:self cancelButtonTitle:@"Back" otherButtonTitles:@"Add New Item", nil];
tableView = [([UITableView alloc])initWithFrame:CGRectZero style:UITableViewStyleGrouped];
tableView.delegate = self;
tableView.dataSource = self;
tableView.backgroundColor = [UIColor clearColor];
[av addSubview:tableView];
[av show];
如何实现来自不同控制器的委托方法?
因为当我添加
@interface mainController : CustomController<CustomDelegateMethod>,UIViewController<UITableViewDelegate, UITableViewDataSource>
它抛出错误Expected identifier or '('
如果我像这样添加 tableview 委托方法
@interface mainController : CustomController<CustomDelegateMethod,UITableViewDelegate, UITableViewDataSource> ,运行应用程序时不会调用委托方法。
【问题讨论】:
-
那么你的问题是什么?
标签: ios objective-c uitableview ipad uiviewcontroller