Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top