I have a an app which has worked perfectly well until the release of IOS 5. I've managed to fix most of the problems caused by the upgrade but I cannot get the keyboard to retract. My other apps manage to do it ok under IOS 5 but I'm missing something with this app. The app scrolls though a large Pdf and the textField is to take the user to a specific page. When the keyboard appears it covers the textField and only the Pdf is visible. Under 4.2 the keyboard retracts when the Pdf is pressed but that doesn't work with IOS 5. I'm using the code below but it doesn't get called, whereas in my other apps which retract the keyboard successfully the code is called, what am I missing.
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
if(textField == pageNo){
[pageNo resignFirstResponder];
}
return YES;
}
Quick fix idea? put this in the pdf view touch handler?
if ([pageNo isFirstResponder]) [pageNo resignFirstResponder];
Related
UPDATE: cut/copy/paste disabled in my app.
I am confused with my iOS app while developing for iPhone devices. Execution flow enters a point like the code below
[self navigationController] pushViewController:chooseDeviceView animated:YES];
[chooseDeviceView release];
[numberTextField setText:#""];
The view changes and things "work properly". The problem is that after this the cut/copy/paste functionality is missing in my app.
Don't really know how to start debugging the issue. Does it ring a bell to anybody?
That was a very complicated issue for a beginner. Finally the issue was a little bit related with status message corrupts main window in my iPhone app
Add in your new viewController this:
- (BOOL)canBecomeFirstResponder {
return YES;
}
It should solve your issue.
I'm a new iPhone developer, so I'd really appreciate some guidance.
I've started off with something...but I don't know what to do from there.
- (BOOL) textFieldShouldReturn:(UITextField *)textField {
//hide keyboard
[textField resignFirstResponder];
//after hiding the keyboard, call another method
//which should display a UITableView
return YES;
}
Please let me know if I can provide more information.
Take a look the Apple developer documentation that cover the topics of ViewControllers and navigation.
This should get you started.
http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html
I'm currently working on an iPhone 4 app with a registration view. The users can focus into a UITextField and I have code that will shift the view upwards to prevent the keyboard from covering up the textfield. But if the app is backgrounded and brought back into the foreground again, the keyboard is still up, the textfield is still in focus, but the view is now shifted back down in its original state. This covers up the textfield.
What's going on? How do I either make the view stay put or hide the keyboard when the app is brought back into the foreground?
UPDATE:
-Any changes for this on the new iOS5?
you could try doing something in applicationDidEnterBackground in your app delegate like
NSLog(#"%#", [self.viewController.YOURTEXTFIELD isFirstResponder]);
if ([self.viewController.YOURTEXTFIELD isFirstResponder]) {
[self.viewController.YOURTEXTFIELD resignFirstResponder];
}
the "isFirstResponder" checks to see if the keyboard is currently being used in this view and returns YES if it is and NO if it isn't.
The NSLog is there just so you know what is getting passed into the if statement.
I've next solution:
In AppDelegate
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// 1. get access to ViewController which is on top
// In my case, I have navigation controller in root
UIViewController* current_controller = [self.rootNavController.viewControllers lastObject];
// 2. loop all uitextfield.
for (UITextField* o_txt in [current_controller.view subviews]) {
[o_txt resignFirstResponder];
}
}
Look's like "hot fix" )
- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController {
[self dismissFirstResponder];
return YES;
}
-(void)dismissFirstResponder {
[nameField resignFirstResponder];
[descriptionField resignFirstResponder];
[helpField resignFirstResponder];
}
I have tried loads of different things, but the keyboard just isn't going down:
I checked to see if my outlets were hooked up correctly in Interface Builder
I put breakpoints inside the 2 methods to check they were being called at the appropriate times, and they were. Those 3 Text Fields are the only ones in the app.
What happens: The popover gets dismissed but the keyboard stays up.
I would really appreciate some help on this matter. It might be a known bug on iOS 3.2, if so any workarounds would be gratefully accepted. Thanks
Make sure the delegate for UITextView the UITextField is assigned
Then call the following method to dismiss any keyboard activity from the view.
[self.view endEditing:YES];
I'm implementing some simple text chatting capabilities in my app and I'm having issues with scrolling the UITextView programmatically. I'm using a UITextView created in Interface Builder that appends a new line and some text to the preexisting text. When the new text is added it should scroll to the bottom.
I built a test application to nail down the concept before adding it to my app. The text in the UITextView updates with the text from a UITextField, however no scrolling occurs.
- (IBAction)enteredText {
CGPoint currentPosition = [textWindow contentOffset];
[textWindow setText:[NSString stringWithFormat:#"%#\n%#", textWindow.text, textInput.text]];
[textWindow setContentOffset:currentPosition animated:NO];
[textWindow scrollRangeToVisible:NSMakeRange([textWindow.text length], 0)];
[textInput setText:#""];
[textInput becomeFirstResponder];
}
I remember implementing a very similar feature in another application I developed a while ago andfrom what I remember the code is similar. The only difference is that the earlier application was for iPhone OS 2 but this one is for 3.0. I read in some forums that the 3.0 beta had some issues with scrolling when the UITextView was created in Interface Builder. I checked the current release notes and I didn't see anything indicating that.
Edit: The IB action is called because text is updated in the UITextView. And "Cancellable Content Touches" is checked.
Edit: Confirmed that the same code works on 2.2.1 but not 3.0
I found that after the user has tapped on the UITextView the scrolling begins to work. So after I loaded this particular view I temporarily set the UITextView as FirstResponder, then the UITextField as FirstResponder:
[myChatRoomViewController.chatWindow becomeFirstResponder];
[myChatRoomViewController.input becomeFirstResponder];
The scrolling then happened automatically, albeit it seemed less smoother than what I remembered in iPhone OS 2.
Are you sure the IBAction is getting called? If so, try making sure that “Cancellable Content Touches” is checked in Interface Builder. This should solve the problem you hinted about in your post.