gpt4 book ai didi

ios - 如何在 iOS 中单击按钮时显示和隐藏表格?

转载 作者:行者123 更新时间:2023-11-29 02:57:38 24 4
gpt4 key购买 nike

我有一个 View Controller 。在 View 中有按钮“显示/隐藏”。当我点击这个按钮时,表格应该显示,当我再次点击这个按钮时,表格应该隐藏。

我正在使用以下代码:

-(void)imageTapped:(UIButton *)sender
{
buttonclk=TRUE;
if (buttonclk==TRUE)
{
[self addTableView];
buttonclk=FALSE;
}
else
{
tableView1.hidden=YES;
}
}

-(void)addTableView
{
CGRect fr = CGRectMake(0,176,320,500);

tableView1 = [[UITableView alloc] initWithFrame:fr style:
UITableViewStylePlain];
tableView1.autoresizingMask = UIViewAutoresizingFlexibleHeight|
UIViewAutoresizingFlexibleWidth;
tableView1.delegate = self;
tableView1.dataSource = self;
tableView1.separatorColor = [UIColor darkGrayColor];
[self.view addSubview:tableView1];
}

当我使用这个码表时是显示而不是隐藏。

最佳答案

-(void)imageTapped:(UIButton *)sender {
if (tableView1.hidden) {
tableView1.hidden=NO;
}
else
{
tableView1.hidden=YES;
}
}

关于ios - 如何在 iOS 中单击按钮时显示和隐藏表格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23708068/

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