Keyboard not showing in UIWebView - objective-c

I am calling
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification object:nil];
method in viewDidLoad, but keyboard dos not appearing when i click on web view.
can anybody tell me why is this happening

You can't make the keyboard show up be calling anything on the notification center. You need an UI element that can handle text input (for example an UITextField, a UIWebView can't handle text input by itself) and than call
[textField becomeFirstResponder]

Related

Remove uialertview in applicationDidEnterBackground

In my app, When I press the home button, I pop the application to rootviewcontroller login class. Now, in the previous class, if any alertview comes and without dismissing it I press home button, Problem appears. Next time I tap on app icon to bring it in fore ground, the login screen is there, but on top of it, previous class alertview is also there. How to remove the alertviews on applicationDidEnterBackground?
Have a global (AppDelegate property or singleton) where you simply store the pointer to the last alert view displayed (and clear it when done). If the pointer is non-nil, dismiss it in DidEnterBackground or wherever.
You can also use UIApplicationWillResignActiveNotification,UIApplicationWillEnterForegroundNotification to solve this issue
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(resignActive)
name:UIApplicationWillResignActiveNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(enterForeground)
name:UIApplicationWillEnterForegroundNotification
object:nil];
In resignActive method you can remove the alertviews...

Looking for some sort of TableViewDidDisplayNotification

I have a split view based app, and would like to listen for some sort of notification for when the root menu is displayed. The reason I want to do this is because the keyboard overlaps the menu, so I would like to hide the keyboard when the menu is displayed.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(keyboardWillHide:)
name:<Some Notification Here>
object:self.view.window];
I already have the method to hide the keyboard, I'm just looking for the appropriate notification.
Thanks!
you can post the notification yourself from the root menu. Just subclass it and post the notification on viewDidAppear or viewWillAppear.
The word of warning: if you are targeting iOS 5 and up you should kep in mind the viewWillAppear and viewDidAppear are deprecated in iOS6. use
willMoveToParentViewController or didMoveToParentViewController or -(void)viewWillLayoutSubviews
-(void)willMoveToParentViewController:(UIViewController *)parent{
if (!parent)
//post notification here
}
Also, you can provide nil as a notification name and listen to any possible notification, then NSLog it out, perhaps you can find a useful notification there, just make sure it is documented to futureproof your product.
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(notificationReceived:) name:nil object:nil];

Difference keyboardDidShow and keyboardWillShow

I have a question. What is the difference between keyboardDidShow and keyboardWillShow? If I put this in my viewDidLoad:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(keyboardDidShow:)
name:UIKeyboardDidShowNotification
object:nil];
What does it mean? Sorry if this is a simple question, but I am not sure. If I enable the rotation of my view, then keyboardDidShow is called twice.
Another question: keyboardWillHide? What is its functionality?
Thanks
keyboardWillShow is fired before the keyboard appears, keyboardDidShow is fired afterwards.
KeyboardWillHide is fired before the keyboard disappears.

Get notifications when a Dailymotion video is played into a UIWebView

I'm currently showing a dailymotion url directly into a UIWebview.
When tapping on the thumbnail image, the video starts playing in fullscreen mode.
The problem is: when the video stops playing or the user tapps the "done" button, the original thumbnail has disapeared from the UIWebview, making it impossible to launch the video again.
I would like to control when the video has finished playing or the user has tapped the done button to reload the UIWebView.
I've been looking around and playing with the Notification center but I couldn't get any response, can you tell me what code I should use ?
loading the video
NSURLRequest *requestObject = [NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.dailymotion.com/embed/video/xh7cgv_cine-pocket-a-candidate_creation"]];
[self.webv loadRequest:requestObject];
notification catch
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(moviePlayerDidExitFullscreen:)
name:MPMoviePlayerDidExitFullscreenNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(moviePlayerDidEnterFullscreenNotification:)
name:MPMoviePlayerDidEnterFullscreenNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(playbackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
thanks,
Louis
corresponding to this thread the MediaPlayer doesn't send out any notifications when started from within the UIWebView (no source given however). you could try these hacks: visible-hidden events hack, timed key window checking-hack, subview events-hack. If you had luck, please share some code!

UITableView Trouble

My navigation Controller 's Root viewController is UIViewController(rootViewController).
It contain's a UITableView, as follows:
alt text http://www.freeimagehosting.net/uploads/c9b0985b63.png
When i press the arrow button(call the function in rootViewController), the tableview will move to left until only the arrow button left on the left edge.
But now i also want to press the cell to make the same function. But the problem is the method didSelectRowAtIndexPath: cant call that function in rootViewController. So how should make this ?
I guess use addObserver method, but know nothing about this , anyone can explain or give me some idea , thanks a lot!
Two ways:
1.Make the "Map" view controller is the delegate of navigation view controller. Then in
didSelectRowAtIndexPath:
call the [delegate buttonPressed];
2. When the button was pressed first time, add a observer:
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(buttonPressed:) name:#"flip_the_navigation_controller" object:nil];
Then when the cell was pressed, post a notificatoin:
[[NSNotificationCenter defaultCenter] postNotificationName:#"flip_the_navigation_controller" object:nil];
And remove the observer in dealloc method:
[[NSNotificationCenter defaultCenter] removeObserver:self];