Iphone web application problem on iphone keyboard open - iphone

I have a problem of layout in view my website on iphone/Ipad, when the iphone keyboard open The whole website moved to top due to which user will not be able to view the top content while the keyboard is open. When keyboard is close the website will be back to its original position.

Implement the below nottification methods in init method of the controller showing your website:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(keyboardWasShown:)
name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(keyboardWasHidden:)
name:UIKeyboardDidHideNotification object:nil];
try setting the frame of your website in the corresponding notification methods (keyboardWasShown,keyboardWasHidden). Eg:- Say your webSiteView is the view disaplying your website and x,y are the coordinates of the view when keyboard is not visible. When the keyBoard is shown, set the frame of the webSiteView with the new x1 and y1 coordinates that will show the view the way you want.
- (void)keyboardWasShown: (id)sender {
[webSiteView setFrame:CGRectMake(x1,y1,w,h)];
}
- (void)keyboardWasHidden: (id)sender {
[webSiteView setFrame:CGRectMake(x,y,w,h)];
}
Also if you are not able to see the entire webSite, try adding your webSiteView into a scrollView and set the frame of the ScrollView in the notification methods.

Related

Web view is blank after watching video in full screen

In my app, i open a html page which contains a video. when i try to get back from watching video from full screen.
The Web view is disappear.
I don't know why this happen.
My code is as follow:
-(void)viewWillAppear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(update:) name:#"UIMoviePlayerControllerWillExitFullscreenNotification" object:nil];
}
it also goes into update method but webview is not shown to me.

UINavigationBar height is reducing after re-enteringforeground

My controller main view call
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:YES];
in it's viewDidAppearmethod because the screen must be manually rotated for the user.
Everything works perfectly except when I put the app in background and I re-enter foreground on this screen: Then the navigationBar's height become 32px.
If I comment the setStatusBarOrientation call, then no problem.
I've logged the navigationBar height in didEnterForeground method (after the super call), but it tells 44px. So I guess it would be resized after.
So I would like to know :
If there was a way to prevent the navigationBar to be resized
If no, what other callback method would come after the didEnterForeground one (viewWill/DidAppear does'nt)
Thanks !
After 4 months, I finally found a partial solution !
If no, what other callback method would come after the didEnterForeground one (viewWill/DidAppear does'nt)
I found a good callback when a viewController (not app delegate) is re-entering foreground. With NSnotificationCenter
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(willEnterForeground:) name:UIApplicationWillEnterForegroundNotification object:nil];
don't forget to remove
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil];

Can I disable the keyboard from showing in a UIWebView?

Is it possible to disable the keyboard from showing when a webpage element is selected inside a UIWebView?
Register for a keyboard notification:
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(keyboardWillShow) name:UIKeyboardWillShowNotification object:nil];
And then you can stop it from showing by placing the following code in keyboardWillShow :
UITextField *dummyTextField = etc.
//Basically, create a dummy uitextfield that you never show.
//I can't remember all the syntax :)
[dummyTextField becomeFirstResponder];
[dummyTextField resignFirstResponder];
//Keyboard should be gone. Hoorah!
Not sure 100% if this will work without flaws. If the keyboard starts to animate then hides itself again, you could use
[UIView enableAnimations:NO];
If the keyboard doesn't like being resigned while it's showing then you could try changing the inputView property of the dummy textField to some dummy UIView instead.
Hopefully this should get you somewhere!

iphone: Preserve view on top of mpMoviePlayerController

I have a mpMoviePlayerController, and I have subview on top of it. When the user taps the fullscreen button of the mpMoviePlayerController, the subview disappears, and only appears when I go back to the original size. Is there a way to keep the subview? Is there a way to get a reference of the "scaled" moviePlayer?
Quick Draft:
trap MPMoviePlayerWillEnterFullscreenNotification like this:
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:#selector(MPMoviePlayerDidEnterFullscreen:)
name:MPMoviePlayerDidEnterFullscreenNotification
object:nil];
within MPMoviePlayerDidEnterFullscreen, add that subview onto the current keyWindow like this:
[[[UIApplication sharedApplication]
keyWindow]
addSubview:mySpecialSubview]

Returning from dismiss modal view controller - any way to detect?

Wonder if anyone can help me. I have a setup whereby a main menu presents the main game as a modal view controller. At this point it also stops playing the main menu music.
The problem is that when the game view controller dismisses itself (e.g when user quits game) and returns to the main menu I cannot get the main menu music to start playing again.
Is there some way I can get the music in the main menu to start playing again ? E.g a delegate method that is called when the main game dismisses ?
Thanks,
Martin
You can do it with the NotificationManager
// set up notification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(playMusic:)
name:#"musicNotification"
object:nil];
// send notification
[[NSNotificationCenter defaultCenter] postNotificationName:#"musicNotification"
object:self];
// clean up notification
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
- (void) playMusic:(NSNotification *) notification
{
// play the music here
if ([[notification name] isEqualToString:#"musicNotification"])
NSLog (#"Received musicNotification!");
}