gpt4 book ai didi

ios - iOS8 应用内购买

转载 作者:行者123 更新时间:2023-12-01 18:55:31 25 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Assertion failure in dequeueReusableCellWithIdentifier:forIndexPath:

(22 个回答)


7年前关闭。




我正在尝试在我的应用程序中实现 IAP。因为我是新手,所以我遵循了本教程:(http://www.raywenderlich.com/21081/introduction-to-in-app-purchases-in-ios-6-tutorial)。

我在这部分代码中遇到错误:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];

SKProduct * product = (SKProduct *) _products[indexPath.row];
cell.textLabel.text = product.localizedTitle;

return cell;
}

第一个错误:

原因:'无法使具有标识符 Cell 的单元格出列 - 必须为标识符注册一个 nib 或一个类,或者连接 Storyboard 中的原型(prototype)单元格'-> 我踢出 forIndexPath:indexPath。

然后我只得到这个(无用的)错误:

线程 1:EXC_BAD_ACCESS(代码=1,地址=0xb79a91cf)

我的问题是,iOS 8 有什么改变吗?

PS:我自己补充一点:我还没有激活 ARC,这解决了其他问题。

最佳答案

在 iOS 8(甚至可能是 7)中,默认行为是您将使用名称为“Cell”的原型(prototype)表格单元格。问题似乎是您没有原型(prototype)单元格,因此该单元格为零。

您可以定义原型(prototype)表单元格,也可以像这样显式创建单元格:

UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Cell"];

}

关于ios - iOS8 应用内购买,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27545539/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com