我想创建一个ViewControllers
我的类SlideViewController
的数组,并循环遍历它们为它分配不同的变量名称或循环遍历列表并动态地为我的{{1}分配不同的名称数组索引附加如下:
SlideViewController
以上内容并未将问题分配给我的for (int i=0; i<[_jsonArray count]; i++) {
NSDictionary *dict = _jsonArray[i];
SlideViewController *firstViewController = [[SlideViewController alloc] initWithNibName:@"SlideView" bundle:nil];
//i want to do like this --- SlideViewController *firstViewController[i] = [[SlideViewController alloc] initWithNibName:@"SlideView" bundle:nil];
NSLog(@"weekly Question.... %@",[dict objectForKey:@"weeklyquestion"]);
firstViewController.question.text = [dict objectForKey:@"weeklyquestion"];
[stepsArray addObject:firstViewController];
}
JJGMPageViewController *pageViewController = [[JJGMPageViewController alloc] init];
pageViewController.delegate = self;
[pageViewController addViewControllers:stepsArray];
[self presentViewController:nav animated:YES completion:nil];
,而是覆盖了相同的实例。
答案 0 :(得分:0)
根据我在此行firstViewController.question.text = [dict objectForKey:@"weeklyquestion"];
上看到的内容,您可以设置UILabel或UITextView的文本属性。但是,UILabel或UITextView都不能在该状态下初始化。
相反,请在NSString
中声明SlideViewController
属性,并在for
循环中设置其值。然后,在SlideViewController
viewDidLoad
方法中,将NSString
设置为您的标签或textview的text
媒体资源。