我试图为一个应用程序创建一个简单的选择题功能。我有一个pList,上面有所有的问题、选择题和答案。这些问题有不同数量的多重选择选项。大多数问题有4个选项,而其他问题有5个、6个或7个。我无法改变每个问题中选项的数量。我不知道是应该使用Interface来构建XIB文件,还是应该根据多个选择选项的数量为每个UILabel和UIButton以编程方式创建约束。此应用程序仅为iPad和iOS 7和8。
发布于 2015-02-05 01:12:21
一种选择是让答案驻留在一个UITableView中,然后每个答案都是一个单元格,您可以在Interface中完成这一切。
第二个选择,如果你知道你不会有超过8个答案,是把所有的8个UILabels和设置未使用的标签被隐藏。然后,您可以在接口构建器中完成所有操作,只需在代码中切换隐藏属性即可。
发布于 2015-02-05 01:17:45
Use UITableView
Question fill in section
Answer options fill in rows of section
In number of section
{
return no of questions
}
In number of rows for section
{
return no of answer for that section(question)
}
- (UIView *)tableView:(UITableView *)tableView
viewForHeaderInSection:(NSInteger)section
{
Fill the questions
}
- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
fill the answer
}https://stackoverflow.com/questions/28334532
复制相似问题