I made good progress tonight on TableViews. I did have one problem that I can not seem to solve. I would like to have 3 UITextFields on 1 TableView Cell. In the photo attached you can see the 3 but each one is on a different cell. That was the result earlier, I have changed the code now to try to store the 2 text fields in an array index and then add that to a new array.
Each UITextField is it's own Method so I have 3. I thought I could create a new method that returns an NSArray and that method looked like this.
This is one of the UITextFields so you can see the code
In my viewDidLoad I had this code. I know my problem is the line in red since it crashes. I think I am on the right path trying to add the 3 separate textFields to an NSArray and then adding that array as an object to a new array. So I would end up with 1 Array and at each index would be an Array that contained 3 UITextFields. I think I am close to solving it.
Each UITextField is it's own Method so I have 3. I thought I could create a new method that returns an NSArray and that method looked like this.
Code:
-(NSArray *)allThreeRows{
NSArray *tempArray = [[[NSArray alloc] initWithObjects:[self newFieldItem],[self newFieldMonthly],[self newFieldTotal], nil]autorelease];
return tempArray;
}
Code:
-(UITextField *)newFieldItem{
UITextField *firstOne = [[[UITextField alloc] initWithFrame:CGRectMake(15, 3, 130, 25.)] autorelease];
firstOne.borderStyle = UITextBorderStyleRoundedRect;
firstOne.font = [UIFont boldSystemFontOfSize:17.0];
firstOne.delegate = self;
firstOne.returnKeyType = UIReturnKeyDefault;
return firstOne;
}
Code:
- (void)viewDidLoad
{
[COLOR="Red"]addTextFieldsArray = [[NSMutableArray alloc] initWithObjects:[self allThreeRows], nil];[/COLOR]
self.navigationController.navigationBarHidden = NO;
UIBarButtonItem *newBarItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addTextFieldsToArray)];
self.navigationItem.rightBarButtonItem = newBarItem;
[newBarItem release];
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithRed:1 green:1 blue:0.75 alpha:1];
}