objective c - iphone-sdk: Adding a textfield to UIAlertview does not work in iOS 4? -
I'm trying to add uitextfield
my alterview
. User tries to enter text alterview
is expected to be considered does not overlap much keyboard to shift a little bit up and disappear when pressing a key on the keyboard and Alertview
should change back.
Runs in iOS 3.1.2 (and even 3.2) all this works fine, but as soon as I try to run it under iOS 4, alertview
is incorrect Displayed in position and the keyboard will not disappear. Any suggestions? Insert here my code:
- (minus) addItemAction {workoutName = [[UIAlertView alloc] initWithTitle: @ "new work" message: @ "name your new workout: \ n" Representative: self cancel buttonTitle: @ "cancel" other button titles: @ "end", zero]; WorkoutName.cancelButtonIndex = 0; UITextField * titleField = [[UITextField alloc] initWithFrame: CGRectMake (12.0, 90.0, 260.0, 25.0)]; TitleField.delegate = self; TitleField.borderStyle = UITextBorderStyleRoundedRect; TitleField.returnKeyType = UIReturnKeyDone; [Add workout namevisual: titlefile]; [Showcased show]; } - (BOOL) textFieldShouldReturn: (UITextField *) TextField {[textField Resigns First Responder]; Yes come back } - (zero) textFieldDidBeginEditing: (UITextField *) textField {[UIView Start Permissions: Zero Reference: NULL]; CGAffineTransform myTransform = Cangfen TransformMac Tronsole (0.0, -70.0); [Workout name set transformations: mitransform]; [UIView commitAnimations]; } - (zero) textFieldDidEndEditing: (UITextField *) textField {[UIView Start Permissions: Zero Reference: Zero]; CGAffineTransform myTransform = CGFint TransformMac Tronsole (0.0, 0.0); [Workout name set transformations: mitransform]; [UIView commitAnimations]; Self.newWorkout = textField.text; } - (void) alertView: (UIAlertView *) alertView didDismissWithButtonIndex: (NSInteger) buttonIndex {if (buttonIndex == 1) {if (! Self.newWorkout = @ "TestWorkout") {[self.workoutPlanArray insertObject: [NSDictionary dictionaryWithObjectsAndKeys: Self.newWorkout, @ "titleValue", @ "04.08.10", @ "Date Value", index: at zero] counter; Counter ++; [Self.tableViewReloadData]; }}}
I also use alertview a text field, & amp in your application I am; That's also on iOS 4.0. Its working fine. Here is the sample code: _ In addition to this, you can refer to two methods called keyboard notifications. }
- (zero) showAlert {showAlert = YES; // Boolean variable createNewAlert = [[UIAlertView alloc] initWithTitle: Add @ "before" Message: self CancelButtonTitle: @ representatives "Keep empty text field will be covered" @ "Cancel" OtherButtonTitles: @ "OK", not Equal to]; UITextField * txtName = [[UITextField alloc] initWithFrame: CGRectMake (12.0, 45.0, 260.0, 25.0)]; TxtName.text = @ ""; [TxtName setBackgroundColor: [UIColor whiteColor]]; [TNTN set keyboard operator: UIBevelopAppAlert]; [TxtName setoutCorking type: UITextAutocorrectionTypeNo]; [TxtName setTextAlignment: UITextAlignmentCenter]; [CreateNewAlert addSubview: txtName]; [Create new show]; }
- (zero) keyboard alert: (ID) notification {if (ShowAlert == Yes) {[UIView start permissions: zero reference: NULL]; [UIView Set Animation Duration: 0.3]; [Create new estimate setform: CGF Trans Transmactronation (0, -60)]; [Create new show]; [UIView commitAnimations]; }
- (zero) keyboardWillHide: (ID) notice {if (showAlert == Yes) {[UIView startAnimations: Zero references: zero ]; [UIView Set Animation Duration: 0.3]; [Create new altitude settings: CGFine transforms Mac conversion (0, +60)]; [UIView commitAnimations]; }}
Comments
Post a Comment