UIPageControl:在故事板中创建视图,将它们添加为子项,更改标签的文本

时间:2013-02-28 13:21:27

标签: ios objective-c xcode storyboard

我已经按照本教程: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

在我的图片中我复制了View 1,但我需要能够做到这一点是代码,而不是在故事板上,因为我需要超过100个视图。

0 个答案:

没有答案