I created a view \"CategoryTableView
\" that subclass from UIView
. And CategoryTableView
contains a UITableView
. I added <
You need to use custom delegates to achieve this...
in CategoryTableView.h
@protocol CategoryTableViewDelegate
-(void)pushViewControllerUsinDelegate:(UIViewController *)viewController;
@end
@interface CategoryTableView : UIView
@property (nonatomic, retain) id delegate;
@end
in CategoryTableView.m
@implementation CategoryTableView
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//Create the required UIViewControllers instance and call the delegate method.
UIViewController *viewController = [[UIViewController alloc] init];
[self.delegate pushViewControllerUsinDelegate:viewController];
}
@end
in HomeViewController.h
@interface HomeViewController : UIViewController
@end
in HomeViewController.m
@implementation HomeViewController
-(void)viewDidLoad
{
[super viewDidLoad];
//initialization of CategoryTableView like this...
CategoryTableView *categoryTableViewInstance = [[CategoryTableView alloc] init];
[categoryTableViewInstance setDelegate:self];
}
-(void)pushViewControllerUsinDelegate:(UIViewController *)viewController
{
[self.navigationController pushViewController:viewController animated:YES];
}