2011-11-11 3 views
1

私はUILabelUIButtonを持っているので、UITableViewCellをカスタマイズしました。私はlayoutSubviewsメソッドでフレームを設定しました。そのテーブルは私が3か所で使用しているUITableViewCellをカスタマイズしましたが、私はUIButtonを2番目に削除する必要があります。どうやってするか ?UITableViewCellからボタンを削除するにはどうすればいいですか?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 

    CustomPopTableViewCell *cell = (CustomPopTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) 
    { 
     cell = [[[CustomPopTableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; 
    } 

    cell.accessoryType = UITableViewCellAccessoryNone; 
    if(tableView.tag == e_metadataView) 
    { 
     //cell.mCheakMarkButton.frame=CGRectZero; 
     cell.mTaggedTerm.text = [docInfoCollection objectAtIndex:indexPath.row]; 
    } 
    else if(tableView.tag == e_searchSettingView)   
    { 
     if(indexPath.row == self.currentRow) 
     { 
      [cell.mcheckMarkButton removeFromSuperView]; 
     } 
     cell.mTaggedTerm.text = [searchEngineCollection objectAtIndex:indexPath.row]; 
    } 
    else if(tableView.tag == e_TaggedTermView)//tageed term table 
    { 
     TaggedItems *taggedItem = [documentData.taggedWords objectAtIndex : indexPath.row]; 
     cell.mTaggedTerm.text = taggedItem.keyword; 
     if([self isTappedObjectExist:indexPath.row]) 
     { 
      cell.accessoryType = UITableViewCellAccessoryCheckmark; 
     } 


    } 

    return cell; 
} 

答えて

3

私が使用します。あなたはもちろんのカスタムセル内のビューの仲介レベルを持っている場合

for (UIView* v in cell.subviews) { 
    if ([v isKindOfClass:[UIButton class]]) { 
     [v removeFromSuperView]; 
    } 
} 

を改正することにします。いくつかのボタンがある場合は、それを識別するためにタグを使用します。

+0

はremoveFromSuperview、 "v"は小さいです:) –

関連する問題