0

質問があります: UITableView を動的に初期化するにはどうすればよいですか?

実際、3 つのラベルと 1 つのチェックボックスを持つカスタム セルがあります。私のtableViewには、2つのセクションがあります。テストのために、私は手動で入れました:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 5;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return 2;
}

しかし、表示されているセルのチェックボックスをチェックすると、スクロールすると表示される次のチェックボックスもチェックされますが、したくありません!

そして、次のような 3 つのラベルとチェックボックスを持つクラスを作成したいと思います。

#import <Foundation/Foundation.h>

@interface MyClass : NSObject

@property(strong, nonatomic) NSString *label1;
@property(strong, nonatomic) NSString *label2;
@property(strong, nonatomic) NSString *label3;
@property(assign) BOOL *checked;

@end

このクラス(このクラスのオブジェクトを含む配列)を使用してUITableViewを動的に初期化しますが、これを行う方法がわかりません。

助けてくれてありがとう!:D

よろしくお願いします、

4

1 に答える 1

0

無料の Sensible TableView フレームワークを使用して、次のように 3 つのラベルを追加するだけです。

SCTableViewSection *section = [SCTableViewSection sectionWithHeaderTitle:@"Title"];
[section addCell:[SCLabelCell cellWithText:@"Label 1"];
[section addCell:[SCLabelCell cellWithText:@"Label 2"];
//etc.
于 2013-03-19T03:31:17.110 に答える