I have a UITextfield for entering text. A button triggers a functionality. After completion of the IBAction the UITextfield is getting focused again. After the IBAction I want to keyboard to disappear. What happends now is that due to the IBAction of the button, the keyboards disappears (I'm showing a UIAlert) and after the IBAction the keyboards pop's up again together with the focus in the UITextfield. Is it possible to prevent the UITextfield to be focused after the IBAction?
Before displaying the alert, call [resignFirstResponder] on the UITextField.
Found the problem. While carrying out the operations in the IBAction method I was locking the view with:
[self.view setUserInteractionEnabled:NO];
// do the job
[self.view setUserInteractionEnabled:YES];
This activates the UITextfield again. So I put a [self.hostName resignFirstResponder]; directly behind the setUserInteractionEnabled:YES.
So after coming back from the IBAction nothing is focused.
SOLUTION:
[self.view setUserInteractionEnabled:NO];
// do the job
[self.view setUserInteractionEnabled:YES];
[self.hostName resignFirstResponder];
Related
I have a viewcontroller that will include a WKWebView. My viewcontroller is inside both a navigationcontroller and tabbarcontroller. The WKWebView appears over both of these, hiding the tabs (on the bottom), and the title and back button (on the top), and they only appear when you scroll up or down. How do I fix this.
Found it. Changed the webview's scrollview backgroundColor.
I use an UIScrollView to set the position of a CCLayer (when i drag with the finger). It work fine but in this CCLayer i've got a CCMenu with one button CCMenuItemImage.
When i click on this button it's ok. But if i press the button and drag just a little bit the layer, the button stay pressed and become not responsive.
thanks for your help
The UIScrollView interferes with the touch events received by CCMenu. It was never designed to share its touches with a UIView.
You have these options:
find and fix the issue by modifying the CCMenu class
write your own menu class
don't use UIScrollView or disable its touch input while the menu is active
I think you'll need to modify CCMenu and attempt to disable the scroll view's ability to scroll on touch. Have a look at the UIScrollView properties called scrollEnabled and delayContentTouches.
By the time the CCMenuItem callback has been called, it might already be too late.
I'm trying to programmatically click a UITextField after the user clicks on another UIButton, this way, when the user clicks the button, the keyboard will appear for the UITextField that the button corresponds to. What I'm trying to do is almost the opposite of resignFirstResponder. I haven't found any way to do this so far, anyone have any ideas?
Use UIResponder's becomeFirstResponder method.
I have attached a toolbar with a UITextField and UIButton to the keyboard when it becomes the first responder via the user taping inside the textfield
textField.inputAccessoryView = theToolbar;
Problem is, the toolbar disappears when the keyboard is dismissed, thus preventing any further input.
Any ideas on how to make the toolbar go back to the bottom of the screen rather than off it completely?
I'm thinking a delegate method might help but Im really not too sure. It seems once the inputAccessoryView always the inputAccessoryView :(
Cheers
The input accessory view is automatically dismissed with the input view (the keyboard, in this case). Generally you do not want to have an input accessory view in your view hierarchy. Instead, if you want your toolbar to scroll up when the keyboard is shown, you should follow the guidelines for Managing the Keyboard.
You could try using an additional toolbar that is offscreen as the inputAccessoryView, which could "fake" the appearance of what you are trying to do. Alternatively, have you tried adding the toolbar back to the bottom of the screen using
[self.view addSubview:theToolbar];
when the keyboard reaches the bottom of the screen? You can use keyboard notifications for this.
I am working on an web service based application. I need Loading/waiting imageview that should disable my Tabbar & Navigationbar of the screen till Loading of web service . The issue when I keep the imageview that contains the waiting animation over in my viewcontroller, it disables only self.view. Can anybody please tell what i went wrong?
Regards,
sathish
You can either hide the tab bar by tabbar.hidden=YES or if you want to remove the tab bar from the window and put it again, you need to release the tab bar and then allocate it again...
But releasing the tab bar will make your app crash, so before releasing the tab bar remove it from super view.
[TabBarController.view removeFromSuperview];
[TabBarController release];
then allocate it again and put it on the window
[self createTabBar]; // createTabBar is a function creating a tab bar
[self.window addSubview:TabBarController.view];
[self.window makeKeyAndVisible];