我已经按照本教程:http : //www.wannabegeek.com/?p=168 来设置 UIPageControl。现在您可以在教程中看到,故事板中有 3 个视图。我想做的是:
http://tinypic.com/view.php?pic=f3cs2b&s=6
因为我需要许多具有相同布局的视图(在图片中它只是橙色的背景)我需要能够重用它们并更改其上的文本,或创建一个按钮等。
我可以像这样添加视图:
UIViewController *aViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"View1"];
[self addChildViewController:aViewController];
但是如果我想从视图上的标签更改文本怎么办?
我在想这样的事情:
UIViewController *aViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"View1"];
// Change the text label thats on the viewcontroller, put an image on the UIImage thats on it, etc...
[self addChildViewController:aViewController]; // After all that, add it as a child
//Now I want the same layout template, so I choose the "View1" again
UIViewController *aViewController2 = [self.storyboard instantiateViewControllerWithIdentifier:@"View1"];
// Again change the text label.
[self addChildViewController:aViewController2]; // Add this new one too
// And so on
在我的图片中,我复制了视图 1,但我需要能够做到这一点是代码,而不是在情节提要上,因为我需要超过 100 个视图。