我正在创建一个应用程序,它从plist中获取信息以创建电子目录。我们有许多不同的版本,如果我不必为每个应用程序进入代码并为每个应用程序设置此数量的部分,并且每次我们进行更新,那将是很好的。
我想使用do while循环来完成此任务,但无法弄清楚如何为每个实例重命名我的实例。请参阅附带的代码,非常感谢任何帮助!
scroller = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 44, 320, 387)];
int secNum = 8;
int secTemp = 0;
int frameWidth = self.view.frame.size.width;
int frameHeight = self.view.frame.size.height;
do {
id *sectionViewController = [NSString stringWithFormat:@"svc%d",secTemp];
SectionViewController *sectionViewController = [[SectionViewController alloc] init];
[sectionViewTable setDataSource:sectionViewController];
[sectionViewTable setDelegate:sectionViewController];
sectionViewController.view = sectionViewController.tableView;
sectionViewController.view.frame = CGRectMake(frameWidth*secTemp, 0, frameWidth, frameHeight);
secTemp = secTemp + 1;
[scroller addSubview:sectionViewController.view];
} while (secTemp < secNum);
scroller.contentSize = CGSizeMake(320*secTemp, 387);
scroller.pagingEnabled = YES;
我无法弄清楚其余部分,并且没有在网上找到任何帮助自己的东西。谢谢!
答案 0 :(得分:0)
无法真正得到您的问题...您希望sectionViewController在每个循环中都有另一个名称来访问它吗?
为什么不创建NSMutableArray并将sectionViewController的实例添加到它?所以你可以通过索引收到它。
或者我的问题出错?