0

ios Noobはこちら。TableView各行にいくつかの項目が必要なiOSがあります:UILabel質問をするための A、[はい] ボタン、[いいえ] ボタン、および「1 から 5 のレート」に答えるスライダー。質問が評価を扱う場合にのみ、スライダーは実際にはすべての質問に表示されるわけではありません。

にすべての「ウィジェット」を追加するための最良の方法は何TableView rowですか? プログラムまたはストーリーボードを通じて?また、 を使用する場合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;
        }
4

2 に答える 2

1

ストーリーボードを使用すると、スライダー付きとスライダーなしの 2 種類のセルを作成できます。その後、その行のデータに応じて正しいセルをロードするだけです。

スライダーを非表示にして表示するよりも簡単です。

于 2013-09-17T14:19:07.360 に答える