Disable the Go button in the Keyboard for a UITextfield in iphone app - iphone

My app has a screen where keyboard is always visible. The main element of the screen is a UITextfield. For easy data entering, keyboard is always made visible. When the user finishes entering data and hits Go, the app performs a 4,5 seconds action which is done in the background thread in order to show UIActivityIndicatorView.
My problem is that the Go button on the keyboard still shows as enabled since the logic is performed in the background. The user could potentially hit the Go again causing it to run again.
I am not able to set editable/userinteraction properties to No because then the keyboard disappears. Is there anyway just to disable the Go button or freeze the keyboard until the background thread returns?

You clearly already have a UITextFieldDelegate set up to handle:
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField;
Otherwise, you would not be able to perform accordingly already. Just return NO from that function if the background process is running and the keyboard should not close. Example:
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if (alreadyPressedGo)
return NO;
...
}
However, this will not "disable" the Go button, simply disable its functionality.

I've not tried it (not at an OS X box at the moment otherwise I'd give it a go), but I'm wondering if you couldn't effectively disable it by placing a touch receiving UIImageView or similar on top of it. (You could even set the opacity of the UIImageView accordingly to achieve a greyed out look.)
This is combination with the disabling the operation of the button as #Skyler illustrated should be ideal.

Related

button highlight state and gestures

I've been struggling with this for a while already and some
help would be useful.
Imagine I have a UIButton, which starts in highlighted/selected state.
If a user taps it, then highlighted/selected state changes.
I've implemented this and it works fine. Problems start
for example if user taps inside the button region,
does not release her/his finger, and moves mouse
outside the button area -- at this time my Button
would usually lose highlighted/selected state.
Anyway, I have solved this issue too, by overriding UIControlEventTouchUpOutside
and making button keep the state it had before...
But now another problem comes in, similar to the above,
if a user taps the button, does not release his/her
finger, and moves the finger to the right say (horizontally,
which also makes my dialog for instance go to the right),
then I again lose "selected/highlighted" state....
I believe again some kind of gesture similar to - but different -
than UIControlEventTouchUpOutside is being called which
removes my selected state...
Do you know what can be going in here? Any advice appreciated.
ps. I have fixed all the issues by just setting different images
for normal/selected states using the interface builder.
For the highlighted effect you can use the: setHighlighted of UIButton class.
When you start touching the button set the highlighted property of button to YES.
when you start touch:
yourButton.highlighted = YES;
When you stop touch:
yourButton.highlighted = NO;
I have fixed all the issues by just setting different images for normal/selected states using the interface builder.

Keyboard taking FOREVER to popup on iPhone app while Debugging

In my app which is very basic right now (2 nested TableView menus and a single prebuilt View) my prebuilt View that contains 2 labels, 2 textfields and 1 button acts very strangely.
If I run in debug mode and click on one of the textfields it takes approximately 10-15 seconds before the keyboard pops up and nothing else works while waiting for it.
If I run the Leaks Performance Tool the app runs very snappy with no problem though.
Anyone seen this before? Any idea why it would be doing that?
I'd take a hard look at the memory usage of the App.
Are you doing any thing in the background of the apps while displaying the KB?
I had a similar problem! Strangely enough having tasks running in a background queue were interfering with the keyboard popping up. This was solved by placing the following line in the viewWillAppear which caused the keyboard to pop up when the view loaded:
[myTextField becomeFirstResponder];
i think u wont set up the first responder for that textfield .
verify your first responder to textfield
sounds like u enable that textfield from somewhere else.which is lately.
confirm the delegate is conected to fileowner of textfield

UITextView with "Done" button *and* "Return" key?

I use a UITextView for multiline text entry in my iPhone app, and I have set the "Return" key to display "Done." I've also set up the return key to disable first responder status, so that hitting "done" actually exits the UITextView. However, I also want to enable users to be able to enter multiline text into the UITextView, i.e. to be able to use the "Return" key. Is there any way to make this work on the iPhone/iPad's UI?
I've been struggling with this issue for 5 years waiting for apple to wake up and create some sort of solution for the textfield multiline responding to done button until I decided to create one myself.
there you go:UITextField multiline with hide keyboard option
It'll be time consuming but you could create your own keyboard with both these keys (this can be done by specifiying the Input View for the UITextView ).
Another alternative could be having a button that sits just above the keyboard that would dismiss the keyboard. You can use the UITextView's Input Accessory View which allows you to create a view that sits on top of the keyboard. See here for more information (I'm aware this document is for iPad but it works for all iOS devices - also just to note, both these require iOS 3.2 or greater).
This should only need to be done on the iphone because the iPad keyboard already comes with a dismiss keyboard button as well as a return button.

iphone - forcing button to acknowledge touch programmatically

When you touch a UIButton it hides for a fraction of second and then it executes its action. This fast "blink" is the feedback the user needs to know that the button has been clicked.
In the project I am doing, I need to select the button programmatically, as if the user had clicked it. In other words, the same behavior has the button had been clicked by the user... a fast blink and execution of its action.
Is this possible to do?
thanks for any help.
The change in the appearance of the button is effected by setting the button's highlighted property. The property is automatically set to YES when the user touches down on the button, and back to NO when she releases.
The highlighted property is writable, so you can set it YES yourself to simulate a touch down. You'll probably want to use +[NSTimer scheduledTimerWithTimeInterval:invocation:repeats:] to set it back to NO after a short interval.
It is pretty simple, and probably there is a better solution.
First, use images to your button, and when you have to fire the button, you just change the button's image in the normal state to the pressed image, and after that, replace it back to the original. You can simply do it with a timer.

iPhone UITextView which is disabled becomes first responder when re-enabled

I have an application which has some text views on one of the controllers.
When the application is processing these text views are disabled and have their user interaction disabled.
The problem is that when the text views are re-enabled they respond to any touches made when they where disabled.
This is made even worse because they become the first responder but the code I have written for textViewDidBeginEditing is NOT run... this means that instead of having the done button on the top right of the Nav Bar instead it still presents the submit button instead.
I have tried automatically resigning first responder when they become active but this has no effect.
Does anyone know why these clicks while deactivated take effect when re-enabled and how to stop them. Bear in mind I have tried to resign first responder and disabled user interaction already.
Thanks
Craig
EDIT:
I've just noticed that this problem is not caused by clicks while inactive, but because setting the UITextView to enabled causes it to display the keyboard.
This is a known defect since iPhone OS 2.1...
Release note for 2.2
This is an bug known since iPhone OS 2.1. When you call UITextView.enabled = YES the keyboard appear, see the release note for OS 2.2
Release Note
The workaround is not to useUITextView.enabled at all, instead use [UITextView setUserInteractionEnabled:] when you want to enable or disable the UITextView.
Craig
UITextView does not have a property called enabled. You should use editable instead.
Did you try resigning first responder when text becomes inactive instead of when it becomes active?