我是 iOS 开发新手,正在寻求有关 UITableView 问题的帮助。
好吧,我正在研究有关 UITableView 代码的所有内容,并且在开发过程中,当我尝试重用标识符时(如果界面上没有要创建的单元格),XCode 会显示以下消息:
“‘UITableView’没有可见的@interface声明选择器‘initWithStyle:reuseIdentifier:’
有代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"Cell";
UITableView *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if(cell ==nil)
{
cell = [[[UITableView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease];
}
有人可以帮我吗?
UITableView *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
应该
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
你应该分配一个UITableViewCell
not UITableView
就像你在这里所做的那样。
//should be **UITableViewCell**
cell = [[[UITableView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease];
并且不要忘记稍后归还。
return cell;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)