Type mytableview does not confirm to portocol UITableViewDataResource
2016-11-13 17:47
295 查看
继承UITableViewDataSource报上面这个总是,是重写协议时写错了
override func numberOfRowsInSection(section: Int) -> Int { return 3 }
应该写下面这个
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 3 }
就正确了。
代码如下
// // MyTableView.swift // L02TableView // // Created by Myron on 16/11/13. // Copyright © 2016年 Myron. All rights reserved. // import UIKit class MyTableView: UITableView,UITableViewDataSource{ /* // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. override func drawRect(rect: CGRect) { // Drawing code } */ required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) self.dataSource = self; } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 3 } // override func numberOfRowsInSection(section: Int) -> Int { // return 3 // } func numberOfSectionsInTableView(tableView: UITableView) -> Int { return 1 } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("cell") let label = cell?.viewWithTag(1) as! UILabel label.text = "Hello Table View" return cell! } }
相关文章推荐
- 绑定到异步的ObservableCollection [This type of CollectionView does not support changes to its SourceColl]
- 报错-Type ViewController doesnot conform to protocol
- 错误:error: ISO C++ does not permit 'wxScrolledWindow::sm_eventTable' to be defined as 'MyClass::sm_eventTable'
- Type does not confirm to protocol 'BooleanType.Protocol'
- swift错误: Type "xxx" does not confirm to protocol "BooleanType"
- ORA-23413: table "DCS_BIZ"."TMP_12" does not have a materialized view log
- error: argument of type 'void* (My_Thread::)(void*)' does not match 'void *(*)(void*)'
- This version of Visual Studio .NET does not support source controlled projects. Any changes that you make to this project will n
- The serializable class Myuser does not declare a static final serialVersionUID field of type long
- 解决CMake Error: The source directory "*" does not appear to contain CMakeLists.txt.
- ORA-00942:table or view does not exist
- Proposed solution for the NHibernate exception “Column ‘Reserved Word’ does not belong to table ReservedWords.”
- Column 'column' does not belong to table Table
- Create Table Space (Ora-00942 error:table or view does not exist)
- ORA-00942:table or view does not exist
- Column 'Column Name' does not belong to table Table
- 从解决 websphere 7.0.0.9 中 Parameter type in setter method does not corresponds to predefined 问题中明白的道理
- RMAN-04004: error from recovery catalog database: ORA-00942: table or view doesnot exist 解决方式
- 还有一种情况会出现 ORA-00942:table or view does not exist
- table or view does not exist -- oracle