異なるデータを持つ7つのテーブルビューを含むiosアプリがあります。plistファイルから各テーブルに入力します。ページコントロールが必要で、各ページに1つのテーブルビューが必要です。ページ コントロールを配置しました。最初のページに配置したテーブルは変更されませんでした。他のページで見ました。ページ数と各ページの内容を確認するにはどうすればよいですか? 私はこれを置きます
- (void)viewDidLoad
{
[super viewDidLoad];
int page=pageControl.currentPage;
//pageControlList=[[NSArray alloc]initWithObjects:tabelView,tabelViewq, nil];
pageControlBeingUsed = NO;
self.scrollView.contentSize = CGSizeMake(960, 424);
self.tabelView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStyleGrouped];
NSError *err;
for (page=0; page<7; page++) {
switch ([pageControl currentPage]) {
case 0:{
NSFileManager *fileManager = [NSFileManager defaultManager];
//getting the path to document directory for the file
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSLog(@"%@",paths);
NSString *documentDir = [paths objectAtIndex:0];
NSString *path = [documentDir stringByAppendingPathComponent:@"News.plist"];
//checking to see of the file already exist
if(![fileManager fileExistsAtPath:path])
{
//if doesnt exist get the the file path from bindle
NSString *correctPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"News.plist"];
NSLog(@"plist exist");
//copy the file from bundle to document dir
[fileManager copyItemAtPath:correctPath toPath:path error:&err];
}
// read data from plist file
presedients=[[NSMutableDictionary alloc]initWithContentsOfFile:path ];
Names=[presedients objectForKey:@"Name"];
url=[presedients objectForKey:@"URL"];
NSLog(@"%@",presedients);
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
}
break;
case 1:{
pageControl.currentPage =pageControl.currentPage+1;
NSFileManager *fileManager = [NSFileManager defaultManager];
//getting the path to document directory for the file
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSLog(@"%@",paths);
NSString *documentDir = [paths objectAtIndex:0];
NSString *pathq = [documentDir stringByAppendingPathComponent:@"Quran.plist"];
//checking to see of the file already exist
if(![fileManager fileExistsAtPath:pathq])
{
//if doesnt exist get the the file path from bindle
NSString *correctPathq = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Quran.plist"];
NSLog(@"plist exist");
//copy the file from bundle to document dir
[fileManager copyItemAtPath:correctPathq toPath:pathq error:&err];
}
// read data from plist file
presedientsq=[[NSMutableDictionary alloc]initWithContentsOfFile:pathq ];
NamesQ=[presedientsq objectForKey:@"Name"];
urlq=[presedientsq objectForKey:@"URL"];
NSLog(@"%@",presedientsq);
}
break;
しかし、プログラムはケース1を参照してください(最初のテーブルを配置し、すべてのページに表示されます)。なんで?私の状態が悪いのでしょうか?
よろしく