我使用在我的IOS應用pagemenu鑑於follwing此https://github.com/uacaps/PageMenupagemenu導航右欄按鈕項(不能根據凸片隱藏)
在menuviewcontroller我具有其中在左側我有一個導航條slidemenu按鈕,右邊我有欄按鈕項(被稱爲這是我在storybord加選照片)
下面的導航欄我加入pagemenu視圖4片(含病人,EMR,聊天,處方)
所以根據竊聽我想隱藏/顯示欄按鈕項目(這意味着只爲我想要顯示的EMR選項卡該欄按鈕項(選擇照片),否則我想隱藏(用於佈雷3個標籤),但我不能達到它 這是我在menuviewcontroller viewDidLoad方法
- (void)viewDidLoad {
[super viewDidLoad];
SWRevealViewController *revealViewController = self.revealViewController;
if (revealViewController)
{
[self->_slideOutMenu setTarget: self.revealViewController];
[self->_slideOutMenu setAction: @selector(revealToggle:)];
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
}
self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
UIStoryboard* sb = [UIStoryboard storyboardWithName:@"Main"
bundle:nil];
Patient* controller1 = [sb instantiateViewControllerWithIdentifier:@"patient"];
controller1.title = @"PATIENT";
EMR* controller2 = [sb instantiateViewControllerWithIdentifier:@"emr"];
controller2.title = @"EMR";
Chat* controller3 = [sb instantiateViewControllerWithIdentifier:@"chatViewcontroller"];
controller3.title = @"CHAT";
Prescription* controller4 = [sb instantiateViewControllerWithIdentifier:@"prescription"];
controller4.title = @"PRESCRIPTION";
NSArray *controllerArray = @[controller1, controller2, controller3, controller4];
NSDictionary *parameters = @{
CAPSPageMenuOptionScrollMenuBackgroundColor: [UIColor colorWithRed:60.0/255.0 green:169.0/255.0 blue:128.0/255.0 alpha:1.0],
CAPSPageMenuOptionViewBackgroundColor: [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0],
CAPSPageMenuOptionSelectionIndicatorColor: [UIColor whiteColor],
CAPSPageMenuOptionBottomMenuHairlineColor: [UIColor colorWithRed:70.0/255.0 green:70.0/255.0 blue:70.0/255.0 alpha:1.0],
CAPSPageMenuOptionMenuItemFont: [UIFont fontWithName:@"HelveticaNeue" size:12.0],
CAPSPageMenuOptionMenuHeight: @(70.0),
CAPSPageMenuOptionMenuItemWidth: @(120.0),
CAPSPageMenuOptionCenterMenuItems: @(YES)
};
_pagingMenuView = [[CAPSPageMenu alloc] initWithViewControllers:controllerArray frame:CGRectMake(0.0, 42.0, self.view.frame.size.width, self.view.frame.size.height-38) options:parameters];
if (_currentIndex >= 0 && _currentIndex <= 2){
[_pagingMenuView moveToPage:_currentIndex];
}
[self.view addSubview:_pagingMenuView.view];
}
看到屏幕截圖我連着
代碼,所以我想隱藏的除了EMR標籤 的viewDidLoad中的所有標籤右側導航欄按鈕和viewwill出現在menuviewcontroller方法只調用一次,那些不要求每敲擊菜單時(患者,EMR,聊天,處方)所以我不知道如何實現它 請任何人幫我在這
在此先感謝
這在這個問題上
添加此行
pagingMenuViewController.delegate=self;
對象(pagingMenuViewController)後,對我的作品作爲公認的答案發起的類似下面
pagingMenuViewController = [[CAPSPageMenu alloc] initWithViewControllers:controllerArray frame:CGRectMake(0.0, 42.0, self.view.frame.size.width, self.view.frame.size.height-38) options:parameters];
self.navigationItem.rightBarButtonItem.tintColor=[UIColor clearColor];
pagingMenuViewController.delegate=self;
,我加了這個代表 CAPSPageMenuDele門 ANSD委託方法
- (void)didMoveToPage:(UIViewController *)controller index:(NSInteger)index {
if(index ==1){
[self show];
}else{
[self hide];
}
}
- (void)willMoveToPage:(UIViewController *)controller index:(NSInteger)index{
if(index ==1){
[self show];
}else{
[self hide];
}
}
由於拉維基蘭和Durai Amuthan.H –