我放在一個的UITextField到UIAlertView中移動和它使鍵盤不會與下面的代碼覆蓋它:UITextField在iPhone上的UIAlertView - 如何使其響應?
[dialog setDelegate:self];
[dialog setTitle:@"Enter Name"];
[dialog addButtonWithTitle:@"Cancel"];
[dialog addButtonWithTitle:@"OK"];
UITextField * nameField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)];
[nameField setBackgroundColor:[UIColor whiteColor]];
[dialog addSubview:nameField];
CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0.0, 100.0);
[dialog setTransform: moveUp];
[dialog show];
我也有下面的代碼來處理警報視圖:
- (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@"%d", (int) buttonIndex);
if (buttonIndex == 1) { // OK pushed
NSLog([alert textField].text); // does not log anything
} else {
// Cancel pushed
}}
我也有一個包含UIAlertViewExtended.h文件:
@class UITextField, UILabel;
@interface UIAlertView(Extended)
-(UITextField *)textField;
@end
我的問題是如何獲取文本用戶輸入和我怎麼dismis鍵盤?
感謝, 本
iPhone OS 4.0似乎自動執行轉換的東西,可能我們將不得不引入一個檢查,如果您的基礎SDK是4.0,並且您將支持的最小SDK是3.0,以便CGAffineTransform代碼僅在本機操作系統是3.0或3.1,爲iPhone OS 4.0跳過這部分代碼! – 2010-07-19 07:23:23