我正在开发一个使用分组 UITableView 的测验应用程序,其中我需要将用户的选择限制为每组一个单元格,并且还使每个组只能选择一次该组,以阻止用户更正任何内容潜在的错误答案。有什么办法可以做到这一点吗?
干杯,亚当
最佳答案
您只能在 UITableView 中选择一行,因此这对您来说不是正确的方法。您应该考虑使用附件 View (例如使用 UITableViewCellAccessoryCheckmark
类型)并在委托(delegate)的 -didSelectRowAtIndexPath
方法中处理它 - Apple 文档中有明确描述。
Discussion
The delegate handles selections in this method. One of the things it can do is exclusively assign the check-mark image (UITableViewCellAccessoryCheckmark) to one row in a section (radio-list style). See "Managing Selections" in Table View Programming Guide for iPhone OS for further information (and code examples) related to this method.
关于iphone - 将 iPhone 上分组 UITableView 中的选择数量限制为每组一个单元格/行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2206339/