开发者

How to remove a UITable according to table tag value

开发者 https://www.devze.com 2023-03-22 19:28 出处:网络
Actually what i am doing is here (void)createTable{ mainTableView = [[UITableView alloc]initWithFrame:CGRectMake(x, 0, width, 450) style:UITableViewCellSelectionStyleNone];

Actually what i am doing is here

(void)createTable{
    mainTableView = [[UITableView alloc]initWithFrame:CGRectMake(x, 0, width, 450) style:UITableViewCellSelectionStyleNone];
    mainTableView.scrollEnabled= NO;
    mainTableView.delegate = self;
    mainTableView.dataSource = self;
    mainTableView.allowsSelection = NO;
    mainTableView.tag = i;
    x=x+width+1;
    CGRect frame ;
    frame = axistableView.frame;
    frame.size.width = x;
    frame.size.height = 450;
    axistableView.frame = frame;

    scrollView.contentSize = axistableView.bounds.size;

    [axistableView addSubview:mainTableView];
开发者_JAVA百科    i++;
}

i want to delete all tables.For that i am using following codes.But it remove only last created table.

-(void)removeTable
{
    [mainTableView removeFromSuperview];    
}

please check this. thanks.


You can use this code to remove all tables from a view

for(UIView *v in self.view.subviews) {
  if([v isKindOfClass:[UITableView class]]) {
     [v removeFromSuperview];
  }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消