我有一个问题,我有表视图和第二节的行我已经放置了一个按钮,当我滚动表视图此按钮也出现在其他行,那么我应该如何解决这个问题?按钮添加为表视图showin我其他单元格中的子视图
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *kCellID = @"cellID";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellID];/////self...ramesh
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:kCellID] ;
}
if (indexPath.row==1)
{
cell.accessoryView=[[UIView alloc]initWithFrame:self.warmUpSwitch.frame];
[email protected]"Warm Up(5 min.)";
[cell.accessoryView addSubview:self.warmUpSwitch];
}
if (indexPath.row==2)
{
cell.accessoryView=[[UIView alloc]initWithFrame:self.coolDownSwitch.frame];
[email protected]"Cool Down(5 min.)";
[cell.accessoryView addSubview:self.coolDownSwitch];
}
}
你能告诉你的代码,我怀疑你使用的是可重用的所有细胞,并获得了不需要的细胞按钮以及 – DivineDesert 2013-02-22 07:04:09
Althought这不是一个好方法,但设置可重复使用的标识符到零将帮助你。 – rptwsthi 2013-02-22 07:13:52
请发布您的代码如何添加按钮 – Warewolf 2013-02-22 07:17:42