Reputation: 1173
I have a view controller. In view there is button "show/hide". When I click on this button table should display and when I click on this button again table should hide.
I'm using following code:
-(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];
}
When I use this code table is displaying but not hiding.
Upvotes: 0
Views: 2222
Reputation: 31
-(void)buttonClicked:(UIButton *)sender {
//toggle style
tableView1.hidden=!tableView1.hidden;
}
Upvotes: 0
Reputation: 468
-(void)imageTapped:(UIButton *)sender {
if (tableView1.hidden) {
tableView1.hidden=NO;
}
else
{
tableView1.hidden=YES;
}
}
Upvotes: 1