Class Viewcontrolleri:uiviewcontroller,uitableviewdelegate,uitableviewdatasource {var mytableview:uitableview? Let testvalue:nsstring = "This is the test content \ n This is the test content \ n This is the test content \ n This is the test content \ n This is the test content \ n This is the test content \ NAND This is the test content \ n This is the test content \ n This is the test content \ n This is the n This is the test content \ n This is the test content \ n This is the test content "override Func Viewdidload () {super.viewdidload () View.backgroundcolor = UI Color.gray Mytableview = UITableView (Frame:cgrect (x:0, y:64, Width:view.frame.width, Height:view.frame.heigh T), style:. Plain) Mytableview? Tablefooterview = UIView () Mytableview? delegate = self//set agent Mytableview? DataSource = Self Mytableview?. Estimatedrowheight = Mytableview?
RowHeight = Uitableviewautomaticdimension view. Addsubview (mytableview!) Register Uitableview,cellid for identifier Mytableview with cell reuse? Register (uitableviewcell.self, Forcellreuseidentifier: "Cellid")}/* Note: Our front Viewcontroller inherits UITableView
DataSource @ and Uitableviewcelegate.
If we do not register the following three methods Xcode will be an error ... *///Column number Func numberofsections (in Tableview:uitableview)-> Int {return 1}//number of rows func TableView (_ Tableview:uitableview, numberofrowsinsection section:int)-> Int {return 10}//Create Uitable
Viewcell Func TableView (_ Tableview:uitableview, Cellforrowat indexpath:indexpath)-> UITableViewCell { Let cells = (Tableview.dequeuereusablecell (withidentifier: "Cellid", For:indexpath)) as UITableViewCell Cells.tex Tlabel? Text = TestValue as String return cells}//Click Response Event Func TableView (_ Tableview:uitableview, DIDs Electrowat Indexpath:indexpath) {tableview.deselectrow (At:indexpath, Animated:true)}//Split Line no spacing o Verride func viewdidlayoutsubviews () {Mytableview? Separatorinset =. Zero Mytableview? Layoutmargins =. Zero} func TableView (_ Tableview:uitableview, Willdisplay cell:uitableviewcell, Forrowat indexpath:indexpath) {cell.separatorinset =. Zero cell.layoutmargins =. Zero}