is it possible to disable keyboad(UITextField) without hidding? - iphone

I'd like to disable UITextField's keyboard without hidding.
is it possible?
If it's so, could you show me how to do?
thanx
Carsh

if you implement delegate method of uitextfield
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
return NO;
}
It does not show the keyboard.

I don't believe the UIKeyboard can be disabled without hiding it.
If you'd like to disable user interaction with the keyboard, you could add an extra UIWindow on top of your existing windows.
By overlaying the UIKeyboard with a transparent UIWindow, the user would be able to see the keyboard, without interacting with it.

a haha , i have a very very ugly method. you can creat a view whichs frame = the keyboards frame. [view setBackgroundColor:[UIColor clearColor]]; [self addSubviews:view];

I did not try but this should work:
textField.inputView.userInteractionEnabled = NO;

Related

uipopover hides when keyboard shows

i have an UIpopover with UItextfield in it, when i open popover and tap on uitextfield then keyboard shows, but it hide the popover. How can i show keyboard without hiding UIpopover?
i am calling popover in UIWebView because i use cordova 1.8.1, but i tried it in UIView too, and it hides too.
here code of calling UIpopover :
if (popEl==nil){
popEl=[[Popover alloc] init];
}
if (pcs==nil){
pcs=[[UIPopoverController alloc] initWithContentViewController:popEl];
pcs.delegate=self;
}
[pcs presentPopoverFromRect:CGRectMake(0, 0, 1, 1) inView:self.webView permittedArrowDirections:UIPopoverArrowDirectionUp animated:NO];
P.S. Sorry for my English, i am from Ukraine.
firstly i recommend you to go through the apple documentation of UIPopOverController
for your problem i think you have to deal with the appearance and disappearance of Keyboard here's the solution to handle this problem Check it
Your question is that, when U click on the textField the pop over view should appear,right? if yes, then add this code before you add the popoverview,
[textField resignFirstResponder];

UIButton under hidden UILabel won't work

I have a large UILabel which I am using to cover a bunch of buttons while I do something else.
All I have set initially is myLabel.hidden = YES; so you can't see the UILabel but the UIButtons (below it) won't work anymore.
Is there another setting for the UILabel I can use to allow touches to go "through it" when it is hidden? Thanks.
why use a UILabel to cover your buttons.
just set
UIButton *button;
[button setUserInteractionEnabled:NO];
or
[button setUserInteractionEnabled:YES];
You can use addSubView and removeFromSuperview methods :
When you want to hide your UIButton with your UILabel :
[self.view addSubview:myLabel];
and the contrary :
[myLabel removeFromSuperview];
I am not sure why a hide is stopping the touch events on buttons. Anyways you can explicitly bring the buttons to foreground by the following calls.
[self bringSubviewToFront:button];
The simplest thing to use as a general way to hide or cover things just a straight UIView. set:
[myCoverView setUserInteractionEnabled:YES];
and it will intercept touches and block touches to the buttons below it.
It should stop blocking touches when you hide it or turn the alpha to 0.0;
You can always siwtch the covering views interaction to:
[myCoverView setUserInteractionEnabled:NO];
and touches will pass through it.
If there is some reason that you need the UILabel these methods will work with it also.
[myLabel setUserInteractionEnabled:NO].
Even if is hidden, your label will get the touches anyway. You have to disable that to achieve what u want.
I think you should hide your buttons instead of covering them with a label.
[yourButton setHidden = YES];
[yourButton2 setHidden = YES];
...

How to add a HUD? (iOS)

I am trying to have some controls appear when you push a button and have it disappear when you press a different button. Right now the HUD is comprised of an image view, and some custom buttons in a UIView called "credits". I've managed to have it disappear using:
[credits removeFromSuperview];
How do I have it reappear?
If it's just a UIImageView, you should...
[self.view addSubview:credits];
... assuming you've not released it already. On a side note, there is a really good HUD for iOS here: http://github.com/matej/MBProgressHUD
I believe you can just set the view to be hidden
[self.view setHidden:YES];
While it's hidden, you can also update the view and then show again
[self.view setHidden:NO];
You'd better set their hidden property to whether YES or NO
This method will toggle the UIView credits hidden property
- (void) toggleCredits {
[credits setHidden:![credits isHidden]];
}

Keyboard won't dismiss when popover closes on iOS 3.2

- (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];

iPhone - Problem with UITextView

This is probably an easy thing to do, but I just can't figure it out - how do I end editing athe textview? how can I get the keyboard to disappear? or do I have to click outside it to make it go away?
First, a (to be honest) fairly simple question like this makes me wonder if you've tried reading the documentation, or searching on the internet.
Searching for "Apple documentation UITextView" gives you this link to the class documentation. Similarly, here is the documentation for the UITextViewDelegate.
Searching for "UITextView simple example" gives you this useful example.
Searching for "UITextView dismiss keyboard", the first hit seems to answer your question exactly. (Although he dismisses the keyboard on a return key, which may not be what you want.) (Edit - it seems from your second comment it's exactly what you want.)
P.S. The people above are correct, if a little terse (understandably). You need to implement a UITextViewDelegate. In that delegate, if you want to hide the keyboard on a return key, implement shouldChangeTextInRange, look for a #"\n" and resign first responder if you get it. Alternatively, add a "Done editing" button to your UI, and resign first responder if the user presses it.
Very Easy:
[myTextField resignFirstResponder];
will do the trick.
One way to end editing, tapping outside the textView, is not entirely trivial. Selecting other text views or text fields or activating a navigation control will trigger...
- (void)textViewDidEndEditing:(UITextView *)textView
...on whatever object you've designated as the textView's delegate. You can trigger this yourself by calling...
- (BOOL)endEditing:(BOOL)force
...on the view that contains your text field.
Suppose I have a UITextView inside a UITableViewCell (inside a UITable). I want to enable editing to end by tapping the table. I could do this:
- (void)viewDidLoad
{
[super viewDidLoad];
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(didTapTable)];
[[self tableView] addGestureRecognizer:tapRecognizer];
[tapRecognizer release];
}
- (void)didTapTable
{
[[self tableView] endEditing:YES];
}
Now whenever I tap my table, I end editing. And, as others have said, in textViewDidEndEditing I should be sure to call [textView resignFirstResponder];
[yourTextField resignFirstResponder];
will make the keyboard disappear and editing end.