I have a UIViewController with IBOutletCollection of UIButtons. The thing I'm trying to get is to have several view controllers with only difference is the amount of same buttons in the outlet collection. What is the correct way to implement that? Assume that layouts of view controllers could be designed in storyboard.

How should I do that? Thank you.

有帮助吗?

解决方案

Something like this you can't do it storyboard. Create a UIViewcontroller with a method.

- (instancetype)initWithButton:(NSArray*)buttonsArray
{
    self = [super init];
    if (self) {
        self.buttonsArray = buttonsArray;
    }
    return self;
}

-(void)viewDidLoad{
 // add buttons to root view here
}

Now create instances of this viewcontrollers with different buttons array.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top