私は最初のアプリに取り組んでおり、Objective-C は初めてです。誰かが a を入力text field
してからボタンを押すと、それが a に保存されるようにしたいと考えていますtable view
。誰もこれを行う方法を知っているか、チュートリアルを知っていますか?
4152 次
2 に答える
1
ボタンを押すたびに、テーブルビューを更新/更新するだけです。
- (IBAction)buttonPressed:(id)sender {
NSString *textNameToAdd = yourTextField.text;
[containerArrayForTableView addObject:textNameToAdd];
[myTableView reloadData];
}
// UITABLEVIEW DELEGATES
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
// Return the number of rows in the section.
// Usually the number of items in your array (the one that holds your list)
return [containerArrayForTableView count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//Where we configure the cell in each row
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell;
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell... setting the text of our cell's label
cell.textLabel.text = [containerArrayForTableView objectAtIndex:indexPath.row];
return cell;
}
UITableView での設定に問題がある場合は、こちらを参照してください。
于 2013-10-12T06:07:27.593 に答える
0
これらはあなたのためのいくつかの良いチュートリアルです..
http://www.appcoda.com/ios-programming-tutorial-create-a-simple-table-view-app/
http://www.codigator.com/tutorials/ios-uitableview-tutorial-for-beginners-part-1/
http://iosmadesimple.blogspot.in/2012/10/adding-uitableview-tutorial.html
ハッピーコーディング。
編集:
ここに私があなたのために作ったものがあります:
TextField と TableView を使用した簡単なデモ
編集2:
于 2013-10-12T05:45:49.497 に答える