- (void) showTextField{ UITextField * textField = [[[UITextField alloc] initWithFrame:CGRectMake(0, 100, 200, 40)] autorelease]; textField.borderStyle = UITextBorderStyleRoundedRect; // 線の種類 textField.clearButtonMode = UITextFieldViewModeAlways; // 初期化ボタンの表示 textField.font = [UIFont fontWithName:@"AmericanTypewriter" size:[UIFont systemFontSize]]; // フォント textField.textAlignment = UITextAlignmentRight; // アラインメント textField.textColor = [UIColor blackColor]; // 文字色 textField.placeholder = @"デフォルトで何か書いておける"; // デフォルトで書かれている薄いアレ textField.keyboardType = UIKeyboardTypeDefault; // キーボードの種類 textField.returnKeyType = UIReturnKeyDone; // 右下のボタン [textField addTarget:self action:@selector(showAlertText:) forControlEvents:UIControlEventEditingDidEndOnExit]; [self.view addSubview:textField]; } - (void)showAlertText:(id)sender { UITextField * textField = sender; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"テキスト入力" message:textField.text delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; }
テキストフィールドを描画して、値を入れ終わったらアラートビューで表示してみるとか。あ、アラートビューのデリゲートメソッドは別途ね。
0 件のコメント:
コメントを投稿