开发者

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 k开发者_StackOverfloweyboard and then saves it as an entry in the UITableView..

could someone show me how i would do this?


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.


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;

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜