I'm struggling when i try to create 11 text fields programmatically. The problem is that the text fields doesn't show up. I'm creating them in the viewDidLoad method.
Here's the code i'm using:
- (void)viewDidLoad
{
// Determine some basic info
int numberOfTextfields = 11;
int textfieldHeight = 40;
int textfieldWidth = 200;
// Create the UIScrollView
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, numberOfTextfields*textfieldHeight,textfieldWidth)];
// Create all the textfields
NSMutableArray *textfields = [NSMutableArray arrayWithCapacity:
(NSUInteger)numberOfTextfields];
for(int i = 0; i < numberOfTextfields; i++) {
UITextField *field = [[UITextField alloc] initWithFrame:
CGRectMake(0,i*textfieldHeight,textfieldHeight,textfieldWidth)];
[scrollView addSubview:field];
[textfields addObject:field];
}
[super viewDidLoad];
}
Any clues on why they don't show up?
Thanks in advance.