私はToDoリストアプリを作成しようとしていますが、テキストボックスの入力されたテキストをチェックボックス付きのボックスに入れて完了に変更できるようにする方法を一生理解できないようです。
誰でも私を助けることができますか?私は Xcode を使い始めたばかりなので、なぜ/どのように機能するのかを説明してください。将来のために学ぶことができます。みんなありがとう!
アプリのレンダリング (私が作ろうとしているもの)
現在Xcodeで(私がこれまでに持っているもの)
私はToDoリストアプリを作成しようとしていますが、テキストボックスの入力されたテキストをチェックボックス付きのボックスに入れて完了に変更できるようにする方法を一生理解できないようです。
誰でも私を助けることができますか?私は Xcode を使い始めたばかりなので、なぜ/どのように機能するのかを説明してください。将来のために学ぶことができます。みんなありがとう!
アプリのレンダリング (私が作ろうとしているもの)
現在Xcodeで(私がこれまでに持っているもの)
追加ボタン用の 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];
}