我有表格视图,在第二部分的行中我放置了一个按钮,当我滚动表格视图时,这个按钮也会出现在其他行中。
- (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];
cell.textLabel.text=@"Warm Up(5 min.)";
[cell.accessoryView addSubview:self.warmUpSwitch];
}
if (indexPath.row==2)
{
cell.accessoryView=[[UIView alloc]initWithFrame:self.coolDownSwitch.frame];
cell.textLabel.text=@"Cool Down(5 min.)";
[cell.accessoryView addSubview:self.coolDownSwitch];
}
}