如何修复cell.contentView.addSubview swift中的错误?

时间:2015-01-14 17:01:07

标签: ios uitableview swift

我的代码有问题,但我不明白在哪里?

滑动表视图后,

正在下降!

喜欢这张图片:http://s18.postimg.org/xgszi1l21/problem.png

d func tableView(tableView:UITableView,cellForRowAtIndexPath indexPath:NSIndexPath) - > UITableViewCell {

    var cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell



        //        MARK: إنشاء ليبل عنوان القسم
        let lblSectionName:UILabel = UILabel(frame: CGRect(x: 60, y: 7, width: self.view.frame.width - 70, height: 10))
        lblSectionName.text = arraySectionName[indexPath.row] as? String
        lblSectionName.textAlignment = NSTextAlignment.Right
        lblSectionName.font = UIFont.systemFontOfSize(18)
        lblSectionName.textColor = UIColor(netHex: 0x1484c4)
        //        lblSectionName.backgroundColor = UIColor.redColor()


        //        MARK: إنشاء ليبل وصف القسم
        let lblSectionDescription:UILabel = UILabel(frame: CGRect(x: 65, y: 15, width: self.view.frame.width - 70, height: 45))
        lblSectionDescription.numberOfLines = 2
        lblSectionDescription.text = arraySectionDescription[indexPath.row] as? String
        lblSectionDescription.textAlignment = NSTextAlignment.Right
        lblSectionDescription.font = UIFont.systemFontOfSize(14)
        lblSectionDescription.textColor = UIColor(netHex: 0x757575)



        //       MARK:\إنشاء صورة الأقسام
        let imageName:NSString = arraySectionPathImage[indexPath.row] as NSString
        let imageURL = NSURL(string: imageName)
        let imageData = NSData(contentsOfURL: imageURL!)
        let image = UIImage(data: imageData!)
        let imageView = UIImageView(image: image!)
        imageView.frame = CGRect(x: 4, y: 7.5, width:60, height: 60)
        //        Mark: لعمل الصورة بشكل دائري
        //        imageView.layer.cornerRadius = imageView.frame.size.width / 2  //MARK: لعمل الصوره بشكل دائري
        imageView.layer.cornerRadius = 10.0 //MARK: لعمل منحنيات بالصوره
        imageView.layer.borderColor = UIColor(netHex: 0xb5b5b5).CGColor
        imageView.layer.backgroundColor = UIColor(netHex: 0x4183D7).CGColor
        imageView.layer.borderWidth = 1.5
        imageView.clipsToBounds = true
        //


        //       cell.textLabel?.text = arraySectionName[indexPath.row] as? String

        //        MARK: تغيير لون خلفية View
        view.backgroundColor = UIColor(netHex: 0xfafafa)


        //        MARK: لتغيير لون خلفية Cell

        if((count%2) == 0)
        {
            cell.backgroundColor = UIColor(netHex: 0xf0f0f0)
        }else
        {
            cell.backgroundColor = UIColor(netHex: 0xfafafa)
        }
        count++


        //        MARK: وضع المحتوى في Cell

        cell.contentView.addSubview(lblSectionName)
        cell.contentView.addSubview(lblSectionDescription)
        cell.contentView.addSubview(imageView)



    return cell
}

0 个答案:

没有答案