gpt4 book ai didi

ios - 将多个小部件添加到 ios TableView 行?

转载 作者:行者123 更新时间:2023-11-28 22:26:23 25 4
gpt4 key购买 nike

ios 菜鸟在这里。我有一个 iOS TableView,它需要在每一行中包含一些项目:用于提问的 UILabel、是按钮、否按钮和用于回答“评分”的 slider 在 1 到 5"之间。只有当问题涉及评级时, slider 实际上不会显示在每个问题上。

将所有“小部件”添加到 TableView 行 的最佳方法是什么?以编程方式还是通过 Storyboard?另外,如果我使用 storyboards,我将如何隐藏评级栏然后在需要时再次显示它?

更新了代码片段

    @property (strong,nonatomic) NSMutableArray *ObjQuestions;
...

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

// Configure the cell...
OBJ_Question *q1 = [self.ObjQuestions objectAtIndex:indexPath.row];
cell.textLabel.text = q1.QuestionText;

// need to access second and third Label widgets from storyboard here
// as well as show/hide NSSlider
return cell;
}

最佳答案

您必须继承 UITableviewCell 并将您的自定义项添加到 UITableViewCell 的内容 View 中。在您的 UITableView 数据源和委托(delegate)方法中使用您的 custometableview 单元格。如果您需要比这更多的信息,请告诉我,我可以为您提供示例代码

关于ios - 将多个小部件添加到 ios TableView 行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18837434/

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