Ibz
Ibz

Reputation: 518

Add User Input to UITableView

I want make an iphone app that has a UITableView that displays different texts written by the user..

basically the user inputs some text via the iphone keyboard and then saves it as an entry in the UITableView..

could someone show me how i would do this?

Upvotes: 1

Views: 3125

Answers (2)

Vinu
Vinu

Reputation: 21

NSMutableArray *Array = [[NSMutableArray alloc] init];

-(void)txtFieldreturn
{
[Array addObject:[NSString stringWithFormat:@"%g",[txtField1.text floatValue]]];
[tableView1 reloadData];
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [container count];
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier=@"cell";
cell=[tableView1 dequeueReusableCellWithIdentifier:cellIdentifier];

if(cell==nil)
{
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:cellIdentifier];
}
if(tableView==self.tableView1)
{
cell.textLabel.text=[Array objectAtIndex:indexPath.row];
}
cell.textLabel.font=[UIFont boldSystemFontOfSize:14];
return cell;

}

Upvotes: 1

Jhaliya - Praveen Sharma
Jhaliya - Praveen Sharma

Reputation: 31722

you can use either UITextField or UITextView for getting input text from user in your UITableViewCell and text input views can be added as subviews to UITableViewCell.

Upvotes: 1

Related Questions