I,
I try to manage the appearance of a tableView inside a scrollView, when a longTapGesture is recognized. This tableView must disappear when longTapGesture is ended. I use the setHidden function inside two “if” blocks for the appearance and disappearance of the tableView. It work after the first longTapView, but after, the tableView does not appear any more.
I suppose there’s a problem with the setHidden function. Here is my code:
-(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer
{
if(self.tableView==nil)
{
NSLog(@"tableView initiee");
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(gestureRecognizer.view.center.x - 10, gestureRecognizer.view.center.y - 10, 100, 100)];
[self addSubview:self.tableView];
}
self.tableView.layer.cornerRadius = 20.0;
self.tableView.layer.frame = CGRectInset(tableView.layer.frame, 20, 20);
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
[self.tableView setHidden:NO];
NSLog(@"tableView apparait");
}
if(gestureRecognizer.state == UIGestureRecognizerStateEnded)
{
[self.tableView setHidden:YES];
NSLog(@"tableView disparait");
}
}
I think I may have found your problem.
self.tableView.layer.frame = CGRectInset(tableView.layer.frame, 20, 20);decreases the the width and height of your table view’s layer by 40 every time it is called. So by the second call, you have a 20×20 frame with a corner radius of 20. This will not be visible. Try commenting that line out and see if it works.What are you trying to accomplish with that line of code?