页面控制和表格视图

时间:2012-11-29 07:11:01

标签: objective-c

我的ios应用程序包含7个具有不同数据的表视图。我从plist文件填充每个表,我需要页面控制,在每个页面我需要一个表视图。我把页面控件,我把它放在第一页的表没有改变,我在其他页面看到它。如何确定每个页面的页数和内容?我把这个

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

但程序看到案例一(我把第一个表放在所有页面中)。为什么?我的病情有问题吗?

此致

0 个答案:

没有答案