我试图将UIButton添加到tableView中,但是当我执行以下操作时:
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frameWidth, 200)];
UIButton *addSource = [UIButton buttonWithType:UIButtonTypeCustom];
[addSource addTarget:self action:@selector(addBoard:) forControlEvents:UIControlEventTouchUpInside];
[addSource setImage:[UIImage imageNamed:@"addsource.png"] forState:UIControlStateNormal];
[addSource setBackgroundColor:[UIColor grayColor]];
[headerView addSubview:addSource];
self.tableView_.tableHeaderView = headerView;
我在那里没有看到UIButton。当我尝试使用UILabel时,它在那里。为什么是这样?
最佳答案
您的addSource按钮没有任何框架。