UITableView Using Swift

前端 未结 10 1439
温柔的废话
温柔的废话 2020-12-08 07:27

My TapCell1.swift

This is Custom UITableViewCell View

import UIKit

class TapCell1: UITableViewCell
{
    @IBOutlet var         


        
10条回答
  •  有刺的猬
    2020-12-08 08:22

    If you are not using Storyboard then create a new file as subclass of UITableViewCell check the checkbox "also create xib files" after that set your custom cell .and here is the code for tableview

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
       {
    
        var customcell:CustomTableViewCellClass? = tableView.dequeueReusableCellWithIdentifier("cell") as? CustomTableViewCellClass
        if  (customcell==nil)
        {
            var nib:NSArray=NSBundle.mainBundle().loadNibNamed("CustomTableViewCellClass", owner: self, options: nil)
    
            customcell = nib.objectAtIndex(0) as? CustomTableViewCell
        }
    
        return customcell!
    
    
    }
    

提交回复
热议问题