創建了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