J'ai donc deux vues, les premières ont mon TableView et les secondes ont mon TextField et je veux ajouter une ligne dans mon TableView avec le texte dans mon TextField.Ajouter une ligne dans un TableView
Pour le moment, je peux juste ajouter une ligne avec
[myTableView addObject:@"Test 1"];
[myTableView addObject:@"Test 2"];
[myTableView addObject:@"Test 3"];
Merci pour votre aide!
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
NSString *cellValue = [myTableView objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [myTableView count];
}
okok j'ai ajouté mon code – Alex
okok merci, mais le problème est que mon TextField n'est pas lié à mon Tabl eView alors comment puis-je ajouter une ligne? – Alex
et myTableView est un NSMutableArray – Alex