I am creating an iPad app, in this I am dynamically creating the interface in the device, here is the code.
- (void)setUpInterface{
UIScrollView *scrollview = [[UIScrollView alloc] initWithFrame:CGRectMake(10, 10,self.view.frame.size.width-20, self.view.frame.size.height-20)];
int y = 0;
for (int i=0; i < [labelArray count]; i++) {
y=y+75;
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(20, y, 500, 30)];
label.text = [NSString stringWithFormat:@"%@",[labelArray objectAtIndex:i]];
label.backgroundColor = [UIColor clearColor];
label.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth;
[scrollview addSubview:label];
UITextField *textBox = [[UITextField alloc]initWithFrame:CGRectMake(200, y, 500, 30)];
textBox.borderStyle = UITextBorderStyleRoundedRect;
textBox.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth;
[scrollview addSubview:textBox];
}
scrollview.contentSize = CGSizeMake(self.view.frame.size.width-100, y*2);
scrollview.backgroundColor = [UIColor scrollViewTexturedBackgroundColor];
scrollview.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth;
[self.view addSubview:scrollview];
}
At the end when I click on a button I want to get the data entered in each text box separately. How can I implement that? How to assign names to each objects?
Thanks.
1 Answer