Problem description:
A view CategoryTableView is created to inherit the UIView. CategoryTableView contains a UITableView. I add CategoryTableView to HomeViewController as a subclass. HomeViewController is a subclass of UIViewController. Currently, I need to push a new controller when executing didSelectRowAtIndexPath. But how can I push or display Another View Controller in CategoryTableView?
You cannot navigate the Controller in CategoryTableView.
Solution:
CategoryTableView. h
[Plain]
@ Property (retain, nonatomic) parentViewController * parent; // create one property for parent view like this
@ Property (retain, nonatomic) parentViewController * parent; // create one property for parent view like this
CategoryTableView. m
[Plain]
@ Sythesize parent;
-(Void) tableView :( UITableView *) tableView didSelectRowAtIndexPath :( NSIndexPath *) indexPath
{
[Parent. navigationController...]; // preform action
// OR ..
[Parent presentModalViewController:...]; // present modal view
}
@ Sythesize parent;
-(Void) tableView :( UITableView *) tableView didSelectRowAtIndexPath :( NSIndexPath *) indexPath
{
[Parent. navigationController...]; // preform action
// OR ..
[Parent presentModalViewController:...]; // present modal view
}
Parent. m
[Plain]
// While calling your CategoryTableView assign self to your parent object
CategoryTableView * tblView = [CategoryTableView alloc] init];
TblView. parent = self;
// While calling your CategoryTableView assign self to your parent object
CategoryTableView * tblView = [CategoryTableView alloc] init];
TblView. parent = self;