2012-03-08 8 views
1

私の医療用アプリケーションでは、ユーザーがPDFやその他のリソースをDocumentsフォルダにダウンロードしてオフラインで表示できる新しい機能があります。このアプリは、iOS 4.1以降とiOS 5をサポートしています。ユーザーはダウンロードしたファイルの名前をアラートビューで入力します。 iOS 5では、アラートにテキストフィールドを配置するのが簡単になりました。似た外観のためとiOS 4.xで感じ、このコードは、一般的にうまく機能:UIAlertviewのUITextViewはiOS 4.xで動作しません

 alertNameEntryOld = [[UIAlertView alloc] init]; 
     [alertNameEntryOld setDelegate:self]; 
     [alertNameEntryOld setTitle:@"Enter new file name:"]; 
     [alertNameEntryOld setMessage:@" "]; 
     [alertNameEntryOld addButtonWithTitle:@"Cancel"]; 
     [alertNameEntryOld addButtonWithTitle:@"Continue"]; 

     //Check current device orientation. 
     UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation]; 

     //Place text field position appropriate to device position. 
     if (interfaceOrientation == UIInterfaceOrientationPortrait) 
      alertTextFieldOld = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)]; 
     if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) 
      alertTextFieldOld = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)]; 
     if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) 
      alertTextFieldOld = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 30.0, 245.0, 25.0)]; 
     if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) 
      alertTextFieldOld = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 30.0, 245.0, 25.0)]; 

     [alertTextFieldOld setBackgroundColor:[UIColor whiteColor]]; 

     //Auto-capitalize first letter with shift key enabled. 
     [alertTextFieldOld setAutocapitalizationType:UITextAutocapitalizationTypeSentences]; 

     [alertNameEntryOld addSubview:alertTextFieldOld]; 
     [alertNameEntryOld show]; 
     [alertTextFieldOld release]; 

私の不満は、同様に、このコードはiOSの4.1、4.2のために完璧にうまく機能しているという事実に由来し、そしてiPhone上の4.3 iPadのiOS 4.1として。ただし、iOS 4.2または4.3を使用してiPadで実行すると、同じコードがテキストフィールドが欠落したアラートビューを作成します。私のアプリはiPhone用ですが、iPadユーザーがこのエラーに遭遇しないようにしたいとは思っています。 iOSソフトウェアにバグがあるようです。修正や代替案の考えは大変ありがたいです。前もって感謝します。

答えて

3

このようにしてみてください。助けを

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Enter new file name:" message:@" " delegate:self cancelButtonTitle:@"Continue" otherButtonTitles:@"Cancel", nil]; 
UITextView *mTextView = [[UITextView alloc] init]; 
[mTextView setFrame:CGRectMake(20.0, 30.0, 245.0, 25.0)]; 
[alert addSubview:mTextView]; 
[mTextView release]; 
[alert show]; 
[alert release]; 
+1

感謝を。あなたのソリューションは、必要に応じて、テキスト入力のフィールドが表示されるという点で機能します。ただし、カーソルは表示されなくなります。私は、UITextFieldの代わりにUITextFieldを使用するためのソリューションを探し続け、最後にもう少しコードを使って動作するソリューションを見つけました:http://iphonedevelopment.blogspot.com/2009/02/alert-view-with-prompt.html – user183804

関連する問題