我希望能够从我的自定义菜单将视图控制器推送到我的主要子类导航控制器,并且我想使用委托来完成。在我尝试更改视图控制器之前,我尝试了一些更简单的方法,即更改当前视图控制器标题。这是我到目前为止编写的代码,但在 TableView 单元格上点击不会触发委托。(或者看起来)
请指教
-> 根视图控制器 / \ 集装箱集装箱 | | SlideMenuViewController 子类 UINavigationController | | | | | UITableViewController VC1 VC2 VC3 VC4
SlideMenuViewController.h:
@protocol SlidingMenuDelegate <NSObject>
@end
@interface SlideMenuViewController : UIViewController
{
id <SlidingMenuDelegate> delegate;
}
@property (strong, nonatomic) id delegate;
SlideMenuViewController.m:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//do something to send controller
((UIRTLNavigationController *)(self.delegate)).titleForView.text = @"test";
}
我的导航控制器.h:
@interface MyNavigationController : UINavigationController <UINavigationControllerDelegate>
@property (nonatomic, strong) UILabel *titleForView;
我的导航控制器.m:
- (void)showRightMenu
{
...
...
//Some animation to slide the menu out
//Delegate stuff
//Get the storyboard's instance.
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];
SlideMenuViewController *slideMenuVC;
//Get the viewcontrollers instance from the storyboard's instance
slideMenuVC = [storyBoard instantiateViewControllerWithIdentifier:@"slideMenuSID"];
slideMenuVC.delegate = self;
}