gpt4 book ai didi

jquery - 如何隐藏和显示同一栏按钮项目上的 View 按下

转载 作者:行者123 更新时间:2023-11-28 21:32:18 25 4
gpt4 key购买 nike

我以编程方式创建了一个右栏按钮项。 Andi 在我的 View Controller 中放置了一个 UIVIEW。我已经为我的 bar button item 添加了操作。但现在我所做的是,第一次我的 UIVIEW 将被隐藏。当我的条形按钮项目按下时,应该显示我的 UIVIEW。

我需要的是,当单击同一个按钮时,我的同一个 UIVIEW 应该隐藏和显示。这是我的代码;

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_barButton.target = self.revealViewController;
_barButton.action = @selector(revealToggle:);

[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];

UIBarButtonItem *chkmanuaaly = [[UIBarButtonItem alloc]initWithTitle:@"Demo "style:UIBarButtonItemStylePlain target:self action:@selector(nextview)];
self.navigationItem.rightBarButtonItem=chkmanuaaly;

RightMenu.hidden = YES;




}
-(void)nextview{
NSLog(@"Right button pressed");

RightMenu.hidden = NO;



}

我怎样才能再次隐藏我按下相同的右栏按钮项

请帮帮我,谢谢

最佳答案

我已经检查了这段代码。这会起作用:

@implementation viewcontroller
bool isShown = false;

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_barButton.target = self.revealViewController;
_barButton.action = @selector(revealToggle:);

[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];

UIBarButtonItem *chkmanuaaly = [[UIBarButtonItem alloc]initWithTitle:@"Demo "style:UIBarButtonItemStylePlain target:self action:@selector(nextview)];
self.navigationItem.rightBarButtonItem=chkmanuaaly;

RightMenu.hidden = YES;




}
-(void)nextview{
NSLog(@"Right button pressed");

if (!isShown) {
RightMenu.hidden = NO;

isShown = true;
} else {
RightMenu.hidden = YES;
isShown = false;
}



}

如果可行,请告诉我。

关于jquery - 如何隐藏和显示同一栏按钮项目上的 View 按下,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35416135/

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