次のコードは、ダイナミックテキストフィールドの作成のn個の数のためです:あなたはボタン、[更新]をクリックし、セルがtextFldが含まれています。この 1を使用するテーブルビュー、毎回行う方法に
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _count; }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
TextViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
return cell; }
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 30)];
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 30)];
[button setTitle:@"Add TextField" forState:UIControlStateNormal];
button.backgroundColor = [UIColor blueColor];
[button addTarget:self action:@selector(addTextField) forControlEvents:UIControlEventTouchUpInside];
[footerView addSubview:button];
return footerView; }
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 30; }
-(void)addTextField{
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:_count inSection:0];
_count++;
[self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; }
あなたが試したことを示してください! – Rikh
stroyboardに5つのラベルがありますか? –
はい、ボタンのクリックでそれらを表示する必要があります – Abhinav