我想要一个UIButton添加到的tableView,但是当我做到以下几点:添加一个UIButton到的tableView headerView
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没有任何框架? – xonegirlz
你忘了设置一个框架。尝试'[addSource setFrame:CGRectMake(0,0,20,20)]' –