创建了UIView(带内的的UITextField)预先,并使其隐藏的:
// Of course, these instance variable names are made up, and should be changed
self.myModalView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 380)] autorelease];
[self.view addSubview:self.myModalView]
self.myTextField = [[[UITextField alloc] init] autorelease];
[self.myModalView addSubview:self.myTextField];
self.myModalView.hidden = YES;
然后,当用户选择一排,填充文本字段,并显示模态视图:
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath {
// Replace stringAtIndexPath with however your data source accesses the string
NSString* myString = [self stringAtIndexPath:indexPath];
self.myTextField.text = myString;
self.myModalView.hidden = NO;
}
如果你想要看起来,你可以在显示模态视图之前做一些CATransition的东西。
谢谢你,这是实现它的好方法。 – aahrens 2010-11-27 03:20:08