简体   繁体   中英

addSubview to UIScrollView doesn't Show?

I have added a tableView to a UIScrollView in the following fashion

tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,400,320,380) style:UITableViewStyleGrouped];
    tableView.dataSource = self;
    tableView.delegate = self;
    tableView.backgroundView = nil;
    tableView.backgroundColor = [UIColor clearColor];
    tableView.sectionHeaderHeight = HEADER_HEIGHT;
    tableView.tableFooterView = [UIView new];
    [self.scroll addSubview:tableView];

I don't know it's not showing up on screen, I have tried making backgroundColor of tableview as black, and it is showing but no tableview is shown also doing

NSLog(@"%@",NSStringFromCGRect(tableView.frame));

gives correct value, I have added other UIButtons to the scrollview which are visible but UITableView on screen it is not visible?

tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,320,380) style:UITableViewStyleGrouped];
    tableView.dataSource = self;
    tableView.delegate = self;
    tableView.backgroundView = nil;
    tableView.backgroundColor = [UIColor clearColor];
    tableView.sectionHeaderHeight = HEADER_HEIGHT;
    tableView.tableFooterView = [UIView new];
    [self.scroll addSubview:tableView];

Is you set scrollview's delegate? ......

like self.scroll.delegate=self;

i think it may work after this...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM