当我实施任何建议的修复时,应用程序在运行时崩溃.当我编译/运行没有推荐修复的应用程序时,应用程序按预期运行.

原方法如下:
func tableView(_ tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath) -> UITableViewCell {
//this let statement is my original line of code prior to swift 3 conversion and it worked fine
let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier:"Cell")
//i've tried using the statement below instead but still getting same error
//let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
cell.textLabel?.text = userSummaryArray[(indexPath as NSIndexPath).row] as String
cell.textLabel!.font = UIFont(name:"Helvetica Neue", size:17)
cell.accessoryType = .disclosureIndicator
userSummaryTable.rowHeight = 25
return cell
}
Run Code Online (Sandbox Code Playgroud)
在Xcode8中转换为swift 3后,我现在收到有关此方法的警告:
Instance method 'tableView(_:cellForIndexPath:)' nearly matches optional requirement 'tableView(_:heightForRowAt:)' of protocol 'UITableViewDelegate'
Run Code Online (Sandbox Code Playgroud)
建议"修复"警告有两个选项:
Make 'tableView(_:cellForIndexPath:)' private to silence this warning
Run Code Online (Sandbox Code Playgroud)
要么
Add '@nonobjc' to silence this warning
Run Code Online (Sandbox Code Playgroud)
这两个"修复"都会使应用程序崩溃.原始代码在新的swift中运行良好,并且在旧版本的swift中运行良好.这些建议是什么?
很感谢任何形式的帮助.
做那个
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
Run Code Online (Sandbox Code Playgroud)
代替
func tableView(_ tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath) -> UITableViewCell {
Run Code Online (Sandbox Code Playgroud)
Xcode试图帮助你,但不承认
| 归档时间: |
|
| 查看次数: |
529 次 |
| 最近记录: |