InAppPurchase 之后更改 UITableViewCellAccessory。可能的?
我有一个带有 5 个选项卡的 TabBar 应用程序。在第五个选项卡中,我可以毫无问题地管理 InAppPurchase。当用户购买内容并切换到第一个选项卡(它有一个 TableView)时,我想将 UITableViewCellAccessory 从 none 更改为 UITableViewCellAccessoryDisclosureIndicator。
有可能吗?
我不明白应该在哪里插入 UITableViewCellAccessory 的更改。
谢谢, 来自意大利的亚历山德罗。
I've a TabBar Application with 5 tabs. In the fifth tab, I manage the InAppPurchase without problems. When the user buy a content and switch to first Tab (it has a TableView), I would like to change the UITableViewCellAccessory from none to UITableViewCellAccessoryDisclosureIndicator.
It's possibile?
I don't understand where I should insert the change of UITableViewCellAccessory.
Thanks,
Alessandro from Italy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你好,来自意大利的 Alessandro,
那么你要做的就是从
UITableView
类中实现cellForRow:atIndexPath:
方法,在该方法中你可能会有一个条件这种类型:编辑:
为了确保您在购买附加功能后更新
UITableVIew
,您应该检查tabBarController:didSelectViewController:
方法当您的表视图的视图控制器将要重新加载数据时,UITabBarControllerDelegate
对象。Hello Alessandro from Italy,
Well the thing you would have to do is to implement the
cellForRow:atIndexPath:
method from theUITableView
class, in that method you would probably have a conditional of this type:Edit:
To be sure you are updating the
UITableVIew
after you purchase the extras, you should check in thetabBarController:didSelectViewController:
method of theUITabBarControllerDelegate
object when your table view's view controller is going to appear to reload the data.El Developer 的解决方案不太有效,因为
cellForRow:atIndexPath:
仅在首次创建单元格时执行。因此,如果在进行应用内购买之前打开带有 tableViewCell 的选项卡,则该单元格将已经创建,并且没有披露指示器。您需要执行以下操作:
UITableViewCell
实例变量。cellForRow:atIndexPath:
中,当您创建需要获取公开指示符的单元格时,也将实例变量设置为该单元格。El Developer's solution doesn't quite work, because
cellForRow:atIndexPath:
is only executed when the cell is first being created. So if the tab with the tableViewCell is opened before making the in-app purchase, the cell will have been created already, without a disclosure indicator.Here's what you need to do:
UITableViewCell
instance variable.cellForRow:atIndexPath:
when you create the cell that needs to get the disclosure indicator, set the instance variable to that cell as well.