テーブルビューセル(各行)にテキストフィールドを追加するにはどうすればよいですか。このテキストフィールドは各行の中央になります。また、セルの各テキストフィールドにタグを設定して、テキストにアクセスします。
5906 次
1 に答える
4
もちろんできます、小さな例:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"test"];
if(cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"test"] autorelease];
UITextView *tv = [[UITextView alloc] initWithFrame:CGRectMake(0, (cell.contentView.bounds.size.height-30)/2, cell.contentView.bounds.size.width, 30)];
[cell.contentView addSubview:tv];
[tv setDelegate:self];
tv.tag = indexPath.row;
}
return cell;
}
...
- (void)textViewDidEndEditing:(UITextView *)textView {
NSLog(@"%d", textView.tag);
[textView resignFirstResponder];
}
...
于 2012-04-16T07:31:05.130 に答える