Objective c 页控件和表视图
我有一个ios应用程序,它包含7个不同数据的表视图。我从plist文件填充每个表,我需要有页面控制,在每个页面中我需要一个表视图。我放了页面控件,我放在第一页的表格没有改变,我在其他页面看到了它。如何确定每页的页数和内容?我把这个Objective c 页控件和表视图,objective-c,Objective C,我有一个ios应用程序,它包含7个不同数据的表视图。我从plist文件填充每个表,我需要有页面控制,在每个页面中我需要一个表视图。我放了页面控件,我放在第一页的表格没有改变,我在其他页面看到了它。如何确定每页的页数和内容?我把这个 - (void)viewDidLoad { [super viewDidLoad]; int page=pageControl.currentPage; //pageControlList=[[NSArray alloc]initWi
- (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;
但是程序会看到案例一,我把它放在第一个表格中,并出现在所有页面中。为什么?是我的情况不对吗
关于切换页面时是否更改当前页面?不,我不会在必须更改的位置更改当前页面?我是这个领域的新手,你能帮我吗?谢谢Alexander的回复,但我有一个问题,我需要tabel视图来显示存储在plist文件中的数据我如何调用7个tabel我不能这样做!!!??你不能存储指向每个表的指针吗?