I have a main controller which implements methods from a custom class. Now in the main controller I want to add a table within an alert view for which I need to implement UITableView delegate methods. I want to implement something like below
On Clicking the Click Here
Button, an alert view is displayed which contains a table displaying all the items.
CustomController is defined like below
@interface CustomController : UIViewController
PRESENT
in .h file
@interface mainController : CustomController<CustomDelegateMethod>
in .m file
@interface mainController()
REQUIRED
in .h file
@interface mainController : CustomController<CustomDelegateMethod>
// I want to add UIViewController<UITableViewDelegate, UITableViewDataSource>
to the above line.
AlertView code in MainController:
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];
How can I implement delegate methods from different controllers?
Because When I add
@interface mainController : CustomController<CustomDelegateMethod>,UIViewController<UITableViewDelegate, UITableViewDataSource>
it is throwing an error Expected identifier or '('
and if I add the tableview delegate methods like this
@interface mainController : CustomController<CustomDelegateMethod,UITableViewDelegate, UITableViewDataSource>
, delegate methods are not called when I run the application.
Try:
in .h file
in .m file