2013-03-18 55 views
0

我有一个问题:我如何动态初始化UITableView?动态初始化UITableView

事实上,我有一个3标签和1复选框的习惯细胞。在我的tableView中,我有两个部分。只是用于测试,我把手动:

- (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

最好的问候,

回答

0

你可以只使用免费的明智的TableView框架,并添加三个标签是这样的:

SCTableViewSection *section = [SCTableViewSection sectionWithHeaderTitle:@"Title"]; 
[section addCell:[SCLabelCell cellWithText:@"Label 1"]; 
[section addCell:[SCLabelCell cellWithText:@"Label 2"]; 
//etc.