我目前有一个有8行的表格,每个表格都有一个右侧的标签和一个左侧的按钮。我希望我可以隐藏所有的按钮,直到用户按下右上角的“编辑”按钮,然后它们会出现,允许用户与每个表格单元交互。我不知道这是可能的,因为他们在UITableViewCell
S或如果有召唤按钮,每个单元更简单的方法在UITableViewCell中隐藏按钮
UPDATE
好了,所以我已经摆在所有隐藏属性,似乎没有错误,但应用程序不承认任何。尽管它们被设置为初始隐藏,但按钮仍然未被隐藏。这里是我的代码
这里是我的表格单元格代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"BlockCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.textLabel.text = @"Free Block";
UIButton*BlockButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
BlockButton.frame = CGRectMake(225.0f, 5.0f, 75.0f, 35.0f);
[BlockButton setTitle:@"Change" forState:UIControlStateNormal];
[BlockButton addTarget:self action:@selector(Switch:) forControlEvents:UIControlEventTouchUpInside];
Blockbutton.backgroundColor = [UIColor colorWithRed:102/255.f
green:0/255.f
blue:51/255.f
alpha:255/255.f];
Blockbutton.hidden = YES;
[cell addSubview:BlockButton];
return cell;
}
,这里是我的方法的代码:
- (IBAction)Editmode:(UIButton *)sender
{
Blockbutton.hidden = !Blockbutton.hidden;
[self.tableView reloadData];
}
任何想法或想法,可能是什么问题?
这是可能的。按钮有一个“隐藏”属性,您可以将其设置为YES或NO。 – matt 2013-04-29 19:08:51