how do i create more than 40-50 textfields and labels in a single view nad when the textfield selected the keyboard should not hide the textfield.?
You would probably want to create them programmatically - using the Interface Builder to make 40-50 textfields would be pretty time-consuming.
As for the keyboard, you can make your main UIView scrollable, then whenever the keyboard is displayed, check what textfield is selected and scroll it to the upper half of the screen. (If your application is rotatable, make sure "the upper half of the screen" changes definitions depending on your orientation.)
Some sample code for this idea:
// Determine some basic info
int numberOfTextfields = 50;
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];
}
In this code, we first set some variables that determine the behavior of the textfields (their position, appearance, and number), then create the master UIScrollView. Once that's done, we create a bunch of UITextFields with the dimensions specified earlier, simultaneously adding them as subviews of the scrollview and holding them in an array for later reference (if need be).
Later, you'll want to override the becomeFirstResponder:
method for your UITextFields (maybe subclass UITextField here) so that whenever a textfield becomes the first responder and shows the keyboard, it calls setContentOffset:animated:
in the scrollview to display itself.