簡體   English   中英

如何在uitableviewcell中隱藏自定義UIButton?

[英]how to hide custom UIButton in uitableviewcell?

我在一個uitableviews中的行中使用了自定義UItablecell。 但是,customtabelcell有一個我要隱藏在UItableview顯示中的UIButton。 定制表單元是在IB中設計的。 我嘗試了以下代碼,但似乎沒有隱藏uibutton:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{

    if (indexPath.section == 0)
       {
        static NSString *cellIdentifier = @"customTableCell1";
        customTableCell1* myOrderCell1 = (customTableCell1*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];

        if (myOrderCell1 == nil) 
           {
            NSLog(@"Cell created");

            NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"customTableCell1"
                                                                owner:nil
                                                              options:nil];

            for(id currentObj in nibObjects)
               {
                if ([currentObj isKindOfClass:[customTableCell1 class]] ) 
                   {
                    myOrderCell1 = (customTableCell1 *)currentObj;
                   }
               }    
           }
        myOrderCell1.backgroundColor = [UIColor blackColor];
        myOrderCell1.accessoryType = UITableViewCellAccessoryNone;
        **myOrderCell1.AddToCartBtn.hidden = YES;
        myOrderCell1.AddToCartBtn.enabled = NO**;

        return myOrderCell1;
       }    

有人對做什么有任何想法嗎?

謝謝

您確定在IB中設置按鈕插座嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM