我已經採取了部分跟標題讓說如何創建自定義單元格與目標C標籤和文本框
週一,週二,週三......週日etc.also我加入後,「+」按鈕部標題&加入作用該按鈕
下面是代碼和屏幕截圖。
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return [SectionArray count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (section ==0) {
return 0;
}else{
return 3;
}
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [SectionArray objectAtIndex:section];
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
CGRect frame = tableView.frame;
UIView *headerView;
if(section == 0 || section == 7) {
}else{
UIButton *addButton=[UIButton buttonWithType:UIButtonTypeContactAdd];
addButton.frame =CGRectMake(frame.size.width-60, 5, 50,30);
addButton.titleLabel.text = @"+";
addButton.tag =section;
// addButton.backgroundColor = [UIColor grayColor];
[addButton addTarget:self action:@selector(AddTimeSlot:) forControlEvents:UIControlEventTouchUpInside];
UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(30, 10, 100, 30)];
title.text = [SectionArray objectAtIndex:section];
headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
[headerView addSubview:title];
[headerView addSubview:addButton];
}
return headerView;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *cellIdent = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdent];
if(cell == nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdent];
}
return cell;
}
現在我要創建當我點擊「+」按鈕,電池,所以請幫助我。
解釋清楚你的問題。 – Chathurka
嗨chathurka, 我已經添加在表視圖部分按鈕和我那個按鈕我要添加表格單元格爲特定部分 –