我有一個問題,我有表視圖和第二節的行我已經放置了一個按鈕,當我滾動表視圖此按鈕也出現在其他行,那麼我應該如何解決這個問題?按鈕添加爲表視圖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