【问题标题】:Can't initialize UITableViewCell无法初始化 UITableViewCell
【发布时间】:2009-09-14 06:03:14
【问题描述】:
if (cell == nil) {

//cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0, 0, 260, 44) reuseIdentifier:CellIdentifier] autorelease];

//The line above works like a breeze

cell = [[[UITableViewCell alloc] initWithStyle:initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];   //This is the line that is causing me problems
}

这些是错误日志:

/Users/myname/Downloads/myApp/Classes/MyTableView.m: In function '-[MyTableView tableView:cellForRowAtIndexPath:]':

/Users/myname/Downloads/myApp/Classes/MyTableView.m:88: error: 'initWithStyle' undeclared (first use in this function)

/Users/myname/Downloads/myApp/Classes/MyTableView.m:88: error: (Each undeclared identifier is reported only once

/Users/myname/Downloads/myApp/Classes/MyTableView.m:88: error: for each function it appears in.)

/Users/myname/Downloads/myApp/Classes/MyTableView.m:88: error: 'UITableViewCellStyleValue1' undeclared (first use in this function)

/Users/myname/Downloads/myApp/Classes/MyTableView.m:88: warning: no '-initWithStyle::reuseIdentifier:' method found

/Users/myname/Downloads/myApp/Classes/MyTableView.m:88: warning: (Messages without a matching method signature

/Users/myname/Downloads/myApp/Classes/MyTableView.m:88: warning: will be assumed to return 'id' and accept

/Users/myname/Downloads/myApp/Classes/MyTableView.m:88: warning: '...' as arguments.)

【问题讨论】:

    标签: iphone xcode uitableview


    【解决方案1】:

    您是否正在为 OS 3 进行编译?我不相信 OS 2 中存在 UITableViewCellStyleValue1...

    【讨论】:

    • 你如何检查?我相信我正在为 OS 3 编译
    • 检查项目信息,常规部分“所有配置的基础 SDK”:它是 iPhone 设备 3.0 吗?
    【解决方案2】:

    正确的方法是

    initWithStyle:reuseIdentifier:
    

    你正在使用

    initWithStyle:initWithStyle:reuseIdentifier:
    

    只需删除多余的 initWithStyle: 即可。

    【讨论】:

      【解决方案3】:

      UITableViewCellStyleValue1 未在 3.0 之前的 SDK 中定义。检查您正在使用的 SDK。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-08-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-01-15
        • 2020-01-22
        • 2017-03-26
        • 2019-01-05
        相关资源
        最近更新 更多