Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableView中的问题,无需单元重用_Ios_Iphone_Uitableview_Ios7 - Fatal编程技术网

Ios UITableView中的问题,无需单元重用

Ios UITableView中的问题,无需单元重用,ios,iphone,uitableview,ios7,Ios,Iphone,Uitableview,Ios7,我试图在不重用单元格的情况下创建tableview 在 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; cell = [[SignUpUserCell alloc] initWithStyle:UITableViewCellSty

我试图在不重用单元格的情况下创建tableview

- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath  {

static NSString *CellIdentifier = @"Cell";
cell = [[SignUpUserCell alloc] initWithStyle:UITableViewCellStyleDefault
                                     reuseIdentifier:CellIdentifier];
cell.delegate = self;
return cell;

}
但是,这不会加载我的自定义单元格。但当我添加dequeReusableCellWithIdentifier时:它工作得非常好。但是我不想让手机重复使用

- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    SignUpUserCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    if (!cell) {
        cell = [[SignUpUserCell alloc] initWithStyle:UITableViewCellStyleDefault
                                     reuseIdentifier:CellIdentifier];
    }
    cell.keyLabel.text = [parameterDictionary objectForKey:@"secondLabel"];
    cell.textField.text = [parameterDictionary objectForKey:@"secondField"];

    // and some more elements

    cell.delegate = self;
    return cell;
}
如何使用不可重用的TableCell正确创建tableview。我做错了什么???

需要:

return cell;
不是


你确定这就是你实际使用的代码吗

- (UITableViewCell *)tableView:(UITableView *)tableView
     cellForRowAtIndexPath:(NSIndexPath *)indexPath  {

static NSString *CellIdentifier = @"Cell";
cell = [[SignUpUserCell alloc] initWithStyle:UITableViewCellStyleDefault
                                 reuseIdentifier:CellIdentifier];
cell.delegate = self;
return cell;

   }
我问的原因是你没有定义什么是
单元格
,代码应该是这样的吗

- (UITableViewCell *)tableView:(UITableView *)tableView
     cellForRowAtIndexPath:(NSIndexPath *)indexPath  {

static NSString *CellIdentifier = @"Cell";
SignUpUserCell * cell = [[SignUpUserCell alloc] initWithStyle:UITableViewCellStyleDefault
                                 reuseIdentifier:CellIdentifier];
cell.delegate = self;
return cell;

   }

为什么不使用强烈推荐且功能强大的可重用单元呢?您的第一个代码块实际上并没有编译,因为没有定义
单元
。所以我猜你说的不对。值得一提的是,我在我的示例项目中声明了
cell
,使它能够正常工作,但如果可能的话,你应该重新使用这些单元格。你做错了的是“没有做苹果希望你做的事”。在苹果的世界里,这是一个致命的错误。虽然有时你可以成功,但真正的解决办法是遵循苹果的文档和推荐的技术。事实上,我为我的错误感到抱歉。我已经在代码中正确声明了SignUpUserCell*cell。那么你认为问题是什么?我的代码与这里添加的更正代码相同,它不是简单的单元格。您的
SignUpUserCell
看起来像什么?您是否在nib中定义它?不,我使用的是故事板。好的,那么您是否在属性中设置了自定义类名,并且您的标识符是否与您在故事板中输入的内容匹配。如果你展示一些屏幕截图会有帮助吗?正如其他人已经指出的,您应该真正使用可重用的单元
- (UITableViewCell *)tableView:(UITableView *)tableView
     cellForRowAtIndexPath:(NSIndexPath *)indexPath  {

static NSString *CellIdentifier = @"Cell";
SignUpUserCell * cell = [[SignUpUserCell alloc] initWithStyle:UITableViewCellStyleDefault
                                 reuseIdentifier:CellIdentifier];
cell.delegate = self;
return cell;

   }