2 回答

TA貢獻1877條經驗 獲得超1個贊
UITableView其它一些東西在這里不多講,這里的就是講解UITableView的創建。
UITableView的創建有三種方法分別是純代碼、XIB、storyboard。下面就是創建的代碼
1.純代碼的創建
首先實例化UITableView(我所有的創建都是在UIViewController類中完成的)
lettableView =UITableView(frame:UIScreen.mainScreen().bounds, style:UITableViewStyle.Plain)
tableView.delegate=self
tableView.dataSource=self
self.view.addSubview(tableView)
必要的幾個代理方法
func numberOfSectionsInTableView(tableView:UITableView) ->Int{
return1
}
func tableView(tableView:UITableView, numberOfRowsInSection section:Int) ->Int{
return3
}
這一塊是自定義cell
func tableView(tableView:UITableView, cellForRowAtIndexPath indexPath:NSIndexPath) ->UITableViewCell{
letcell=TYCodeTableViewCell.codeTableViewCell(tableView)as!TYCodeTableViewCell
returncell
}
下面是具體用純代碼創建cell
class

TA貢獻1829條經驗 獲得超13個贊
UITableView其它一些東西在這里不多講,這里的就是講解UITableView的創建。 UITableView的創建有三種方法分別是純代碼、XIB、storyboard。下面就是創建的代碼 1.純代碼的創建 首先實例化UITableView(我所有的創建都是在UIViewController類中完成.
- 2 回答
- 0 關注
- 1376 瀏覽
添加回答
舉報