pav*_*lag 7 uitableview ios swift xcode6
我正在尝试使用swift为iOS 8制作应用程序.这里的目标是制作一种新闻源.此Feed显示来自用户的帖子,其遵循特定模式.
我想过使用UITableView,其中每个单元格都遵循自定义布局.当我尝试访问其中的文本标签时出现问题.我尝试通过其标签访问它,但是当我这样做时,整个应用程序崩溃了.报告的错误是"Swift dynamic cast failed",我正在使用以下代码访问该视图:
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
let cellId: String = "cell"
var cell : UITableViewCell = tableView.dequeueReusableCellWithIdentifier(cellId) as UITableViewCell
if let ip = indexPath{
cell.textLabel.text = myData[ip.row] as String
var lbl = cell.contentView.viewWithTag(0) as UILabel
lbl.text = "ola"
}
return cell
}
Run Code Online (Sandbox Code Playgroud)
难道我做错了什么?提前致谢!
| 归档时间: |
|
| 查看次数: |
13759 次 |
| 最近记录: |