-3

私はToDoリストアプリを作成しようとしていますが、テキストボックスの入力されたテキストをチェックボックス付きのボックスに入れて完了に変更できるようにする方法を一生理解できないようです。

誰でも私を助けることができますか?私は Xcode を使い始めたばかりなので、なぜ/どのように機能するのかを説明してください。将来のために学ぶことができます。みんなありがとう!

アプリのレンダリング (私が作ろうとしているもの)

http://imgur.com/wcNXu0z

現在Xcodeで(私がこれまでに持っているもの)

http://imgur.com/PLUVaVg

4

2 に答える 2

0

追加ボタン用の IBAction を作成する必要があります。したがって、ボタンをクリックして入力したテキストを UItextfield に配列に保存すると呼び出され、その配列を使用してテーブルに行を追加します。

たとえば、次のコードを検討してください。

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
        return 1;
    }

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


    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
      static NSString *MyIdentifier = @"MyIdentifier";
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
      if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
      }
      [cell.textLabel setText: [dataArray objectAtIndex:indexPath.row];
      return cell;
    }


    -(IBAction)addCity:(id)sender
    {
      [tableView beginUpdates];
      [dataArray addObject:@"City"];
      NSArray *paths = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:[dataArray count]-1 inSection:1]];
      [[self tableView] insertRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationTop];
      [tableView endUpdates];
   }
于 2013-05-27T09:16:30.623 に答える