iOS開発初心者です。2 ページのページ スクローラーを作成し、テーブル ビューで 2 つの異なる配列からのデータを表示しています。しかし、そのデータをページに表示できません。両方のページで同じ配列を取得しています。ページスクローラーのページのインデックスに関して、テーブルビューでデータを設定しているコードを次に示します。BTIobj は、ページのインデックスが来るクラスのオブジェクトです。
Pagescroller.m
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [appDelegate.tableDetailDataAD count];
}
//CELL FOR ROW AT INDEX PATH
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}
if(BTIobj.indx==0)
{
NSString *title=[[appDelegate.tableDetailDataAD objectAtIndex:indexPath.row] valueForKey:@"date1"];
cell.textLabel.text = title;
NSString *str=[[appDelegate.tableDetailDataAD objectAtIndex:indexPath.row] valueForKey:@"name1"];
cell.detailTextLabel.text=str;
NSLog(@"AD data:%@",[appDelegate.tableDetailDataAD description]);
}
if(BTIobj.indx == 1)
{
[tableView reloadData];
NSString *title=[[appDelegate.tableDetailDataIH objectAtIndex:indexPath.row] valueForKey:@"date1"];
cell.textLabel.text = title;
NSString *str=[[appDelegate.tableDetailDataIH objectAtIndex:indexPath.row] valueForKey:@"name1"];
NSLog(@"AD2 data:%@",[appDelegate.tableDetailDataIH description]);
cell.detailTextLabel.text=str;
[self.indianHolidaysTableView reloadData];
}
//Formatting texts
cell.textLabel.textColor= [UIColor colorWithRed:(0/255.0) green:(153/255.0) blue:(204/255.0) alpha:1] ;
cell.textLabel.font=[UIFont systemFontOfSize:16.0];
cell.detailTextLabel.textColor=[UIColor blackColor];
cell.detailTextLabel.font = [UIFont systemFontOfSize:12];
return cell;
}