0

UITableView以下のコードをリストした があります。

以下に示すように、これらのオブジェクトを分割するにはどうすればよいですか?

数学
代数
幾何
微積分

科学
総合 1
総合 2

コードは次のとおりです。

- (void)viewDidLoad {

    NSArray *array = [[NSArray alloc] initWithObjects:@"Math",@"Science",@"English",@"Social Studies",@"Spanish",@"German",@"French",@"Biology",nil];

    self.listData = array;
    [array release];
    [super viewDidLoad];
}
4

3 に答える 3

0

UITableViewオブジェクトのUITableViewDataSource内。

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
   return array.count;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    return [array objectAtIndex:section];
}

あなたのケースのために「セクショニング」部分を行います。

于 2012-05-11T06:22:52.350 に答える
0
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
   return [yourarray count];
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    return [yourarray objectAtIndex:section];
}
于 2012-05-11T08:17:52.823 に答える
0

セクション化されたテーブル ビューを使用する必要があります。これは、これを実現するための最良の方法です。同じことについては、次のチュートリアルを参照できます - http://www.xcode-tutorials.com/uitableview- –-3-sectioned-table-view/

于 2012-05-11T06:17:29.787 に答える