XCode 4. Keyboard doesn't hide on iPad - objective-c

I have a problem with my iPad app.
I perform authorization in social networks (facebook, twitter etc.) to post information from app. Several webviews change each other (login, content of post, captcha). They have text fields and I have to show keyboard. After posting I return to some start view with posted information.
It works good, but after posting first news something goes wrong. When I post news one more time, after return keyboard is still on the screen.
I saw here some questions familiar to this, but they wasn't useful.
I tried to make resignFirstRersponder to all webViews, textFields and textViews. Also i\I tried to implement method disablesAutomaticKeyboardDismissal but it doesn't help me.
I don't know where search for problem...
So questions are: why could this happened? How can I solve this? fnd How can I get some information about keyboard? (is it visible, what object has focus etc., anything that could be useful to solve problem)
And one more thing. I have similar app for iPhone and it seems to work correct.

Try this:
[searchBar performSelector:#selector(resignFirstResponder) withObject:nil afterDelay:0.1];
Make sure to replace searchBar with the object that is the actual First responder in your case

Problem is fixed, finally. The reason was the way I had changed visible view. I set a new value to view property of ViewController. And as previous view contains text field with focus on it, focus wasn't lost before changing view (and keyboard was still on the screen), but I had lost handler to previous view.
Solution is: resignFirstResponder to all (or current) inputs BEFORE changing view.
Hope, it's clear. Thanks for your help!

Related

Is there any way to highlight the status bar item programmatically?

I'd like to perform the following:
when I click on the status bar item (NSStatusItem) I want to highlight it (no menu) indefinitely and when the application loses focus I want to stop highlighting it.
Is there any way of doing this? I can't find it, tbh.
You can probably do this with a custom view that sends the status item a drawStatusBarBackgroundInRect:withHighlight: message.
I doubt there's any way to do it without a custom view, since, as I mentioned in my comment on the question, keeping the item highlighted when the user doesn't have the mouse down on it looks bad.
Old question, but I think it is worth adding this alternative answer.
This will not automatically un-highlight when the application loses focus, but this allows you to highlight without using a custom view (as the other answer requires):
NSStatusItem *statusItem = [self getStatusItem];
[statusItem.button setHighlighted:YES];
You can unhighlight it manually using the same method:
[statusItem.button setHighlighted:NO];
Note I got this answer from a similar question here.

Customizing the post to facebook in Sharekit2.0

I have integrated the latest sharekit code into my project. I am able to click in, to go to the facebook and able to see the text I am going to post.
I would like to change two things.
Firstly, I am not able to see the cancel or post button because of my app picture at top. So I would like to set the view to be scrollable. How do I change that?
Secondly, I would like to remove the keyboard after I press return, or I want a way to remove the keyboard.
Thirdly, when i click the text edit, it gives me Error: HTTP status code: 404. How to solve this?
Need some help on this..Thanks..
if you use following code it will dissmiss the keyboard.
[self.view Endediting:YES];
ShareKit never seemed to be customizable. Personally, I had displeasure to integrate it into the project to post images to Flickr and Twitter, but nothing else. For what I see there now, ShareKit is still using old FacebookSDK (or at least it look so).
For better customization, I'd suggest to throw away Facebook from your ShareKit and just use new FacebookSDK.
[yourtextview resignFirstResponder];
this will remove the keyboard
Or as a general case, you can use this: [self.view Endediting:YES];

Force the keyboard to become visible and stay visible in view

I want to have the virtual keyboard appear in my view on load and I want it to say visible for the lifetime of the view. There is a text field and I treat as the primary control for this view.
Initially, I called [self.textField becomeFirstResponder] in -viewWillAppear: following advice I've gotten here. Then, I came up with a different idea: I overloaded UIViewController's -becomeFirstResponder.
- (BOOL)becomeFirstResponder
{
if (self.primeResponder)
return [self.primeResponder becomeFirstResponder];
return [super becomeFirstResponder];
}
I'm not seeing any hidden problems with this, but then again, no one recommends it either. Am I missing something? Is this a bad approach? Please help.
In reviewing my old question, I thought now would be a good time provide an answer to this.
It works and does not have any major drawbacks.
I've had good luck with this method except in a peculiar circumstance. I used this to set a text field in a table view cell as the prime responder. In iOS 6, it didn't load the keyboard or highlight the textfield when the view was pushed onto the navigation controller stack.
See In iOS 6, -[UITextField becomeFirstResponder] doesn't work in -viewWillAppear: for my solution to that problem.

possibility of setting the Voice Over Cursor in Objective-C

I am programming a text-based RPG for Voice-Over users on the iPhone.
I've got multiple UIViews added to my viewcontroller for different events.
I often remove and add them to my main View.
My Question is as follows: is it possible to update the VoiceOver Cursor to focus on the first Element on the View so the User doesn't has to check every Time if there has happened something new?
I figured out that this happens in a Navigationcontroller.
Is there a functionality to do this?
By posting a UIAccessibilityLayoutChangedNotification, you inform VoiceOver that the layout of the screen has changed. You can also use UIAccessibilityAnnouncementNotification if you want to make a specific announcement.
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
Reference: UIAccessibility Protocol Introduction, Notifications
You can't control the VoiceOver cursor in iOS 4 or 5. I wish you could, it would solve so many issues.
I think this will be possible with iOS 6. See this answer for more info on that: https://stackoverflow.com/a/11995385/1455770

Delay navigationController to pop detailView of UITableView

Im looking for some help regarding to put a save like confirmation if some changes where made to a UITextField and UISegmentedControl.
Can I prevent the UINavigationController from pop the view? And then pop based on buttons in a AlertView?
I use the UITextField and UISegmented control to POST data to a webservice.
I perhaps need to use a modalView for this? but wanted first to see if someone have another idea, because I would like to keep navigation clicks down if possible.
Any suggestions for this?
Thanks,
Why not just using a UIAlertView?
EDIT: On second thought, and re-reading your question + comment, I would recommend to use a Modal View with classics OK/Cancel buttons + a UIAlertView(s) for confirmation(s). (UIAlertView "poping" on OK/Cancel is easy to do via UIAlertViewDelegate)
That's what Modal views are for, block UI until some user action has been completed. Like a form. This is how I do all my forms, and how Apple does (just look at the create mail screen for an example, or any form of iOS apps)
Adding a "Magical" action requiring user interaction on the back button of a navigation controller is bad in terms of user experience, if you hit back, you expect the view to pop, nothing else. I would then be surprised if Apple SDK even allows to cancel that event...
You can do what you would like without the need of a modal view.
First, you can use your text field's UITextFieldDelegate to set a flag in your controller when the field content is modified. You can reset this flag when the data is sent out.
Then you could override your UIViewContorller's viewWillDisappear to show an alert to the user in case new data have not been posted at the moment the view is going to disappear and give him the possibility of sending it to the server. This method will be called when you move to a different controller in your navigation UI, and you will not have a chance to "reject" the operation.