UIAlertView中的UITextField

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UIAlertView中的UITextField相关的知识,希望对你有一定的参考价值。

  1. - (void) doAlertWithTextField {
  2. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Congratulations!" message:@"You earned a top score! Enter your name:nn"
  3. delegate:self
  4. cancelButtonTitle:nil
  5. otherButtonTitles:@"OK", nil];
  6. alert.tag = kTag_EnterNameAlert;
  7.  
  8. CGRect entryFieldRect = CGRectZero;
  9. if( UIDeviceOrientationIsPortrait( [UIApplication sharedApplication].statusBarOrientation ) ) {
  10. entryFieldRect = CGRectMake(12, 90, 260, 25);
  11. }
  12. else {
  13. entryFieldRect = CGRectMake(12, 72, 260, 25);
  14. }
  15.  
  16. UITextField *nameEntryField = [[UITextField alloc] initWithFrame:entryFieldRect];
  17. nameEntryField.tag = kTag_NameEmtryField;
  18. nameEntryField.backgroundColor = [UIColor whiteColor];
  19. nameEntryField.keyboardType = UIKeyboardTypeAlphabet;
  20. nameEntryField.keyboardAppearance = UIKeyboardAppearanceAlert;
  21. nameEntryField.autocorrectionType = UITextAutocorrectionTypeNo;
  22. nameEntryField.clearButtonMode = UITextFieldViewModeWhileEditing;
  23. [alert addSubview:nameEntryField];
  24. [nameEntryField becomeFirstResponder];
  25. [nameEntryField release];
  26.  
  27. [alert show];
  28. [alert release];
  29. }

以上是关于UIAlertView中的UITextField的主要内容,如果未能解决你的问题,请参考以下文章

uialertview 中的图像...?

iPhone App 中的 UIAlertView 动态

可达性中的 UIAlertView 异常

更改 UIAlertView 中的按钮标题颜色

UIAlertView中的UITextField

UIAlertView 中的 iOS / UITextField