gpt4 book ai didi

ios - pagemenu-navigation 右栏按钮项(不能按tabs隐藏)

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:19:07 33 4
gpt4 key购买 nike

我在我的 iOS 应用程序中使用页面菜单 View ,方法是遵循此 https://github.com/uacaps/PageMenu

在 menuviewcontroller 中,我有一个导航栏,左侧有 slidemenu 按钮,右侧有条形按钮项(称为选择照片,我在 storybord 中添加)

在该导航栏下方,我添加了 pagemenu view 4 选项卡(包含患者、EMR、聊天、处方)

所以根据点击我想隐藏/显示那个条形按钮项(这意味着我只想显示条形按钮项(选择照片)的 EMR 选项卡,否则我想隐藏(重新挖掘 3 个选项卡),但我达不到这是我在 menuviewcontroller viewdidload 方法中的代码 enter image description here

- (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;

我添加了这个代表CAPPSageMenuDelegateansd 委托(delegate)方法

- (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];
}
}

最佳答案

在viewDidLoad方法中添加

_pagingMenuView.delegate = self

然后实现委托(delegate)方法

- (void)didMoveToPage:(UIViewController *)controller index:(NSInteger)index {
if(index ==1){
self.navigationItem.rightBarButtonItem = //your barButton to select photo
self.navigationItem.leftBarButtonItem = nil;
}else{
self.navigationItem.rightBarButtonItem = nil;
self.navigationItem.leftBarButtonItem = //your barButton to reveal the slide menu
}

}

关于ios - pagemenu-navigation 右栏按钮项(不能按tabs隐藏),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40780981/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com