2016-12-30 26 views
-3

變動表中的多項選擇按鈕樣式報告的錯誤不明確的參考成員「子視圖」

NSArray *subviews = [[tableView cellForRowAtIndexPath:indexPath] subviews];/* An array of */ 
     for (id subCell in subviews) { 
      if ([subCell isKindOfClass:[UIControl class]]) { 

       for (UIImageView *circleImage in [subCell subviews]) { 

         circleImage.image = [UIImage imageNamed:@"CellButtonSelected"]; 

       } 
      } 

     } 
    /* change */ 
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) /* table Proxy method */ 
    var subviews = tableView.cellForRowAtIndexPath(indexPath)!.subviews 
    for subCell: AnyObject in subviews { 
     if (subCell is UIControl) { 
      for circleImage: UIImageView in subCell.subviews { /* report an error Ambiguous reference to member 'subviews' */ 
    /* How to solve?*/ 
       circleImage.image = UIImage(named: "CellButtonSelected")! 
      } 
     } 
    } 

報告的錯誤不明確的參考成員「子視圖」

/**Swift, the table of custom boxes, no system, how to change/ 
+3

你的代碼是ObjC和Swift的混合...我不認爲它可以在swift或objective-c編譯器下編譯... – Sweeper

+0

我用swift編程,OC代碼沒問題,變成swift是錯誤 – user7357445

回答

0

也許像這樣的:

for circleImage: UIView in subCell.subviews! { 
    if let circleImage = circleImage as? UIImageView { 
     circleImage.image = UIImage(named: "CellButtonSelected")! 
    }     
} 
+0

好的,有沒有更多的問題,謝謝 – user7357445

+0

何時單元格選擇錯誤 – user7357445

+0

新的問題再次 – user7357445

0
The button click event custom selection button collapsed  

    for row in 0...self.collectionBookList.count { 
       let indexPath=NSIndexPath.init(forRow: row, inSection: 0) 
       self.myTableView.selectRowAtIndexPath(indexPath, animated: false, scrollPosition:.Bottom) 
       let subviews = self.myTableView.cellForRowAtIndexPath(indexPath)!.subviews 
       for subCell: AnyObject in subviews { 
        if (subCell is UIControl) { 
         for circleImage: UIView in subCell.subviews! { 
          if let circleImage = circleImage as? UIImageView { 
           circleImage.image = UIImage(named: "delete")! 
          } 
         } 
        } 
       } 
      } 
相關問題