iphone: Preserve view on top of mpMoviePlayerController - iphone

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]

Related

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

Control done button

I have a view with some objects, one of them is a webview where I play a video, this view change the size and the position of the object when the device rotates. The problem occurs when I am playing the video in full screen, if I start watching the video in landscape and while I am watching the video (full screen) I rotate the device and then I hit the done button when I return to the view the objects are not in the position that they should be in that orientation.
I set the position in a function, I call that function in viewdidload and also in willAnimateRotationToInterfaceOrientation but how can I control the rotation while I am watching the video?
You could do something like this:
-(void) viewDidLoad
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(playerPlaybackDidFinish:) name:MPMoviePlayerWillExitFullscreenNotification object:nil];
}
- (void) playerPlaybackDidFinish:(NSNotification*)notification
{
[self resizeSubviews];
}
So, when the playback finishes, you call your method to resize your subviews, and by the time the player closes, your view should look correct for the orientation.
You could also register for MPMoviePlayerWillExitFullscreenNotification instead, if that more properly fits your needs.

how to call a presentModalView from a subView?

i'm working in ipad application,i have a viewController A which have many subviews viewcontroller b,c,d,e,f... when i want to select a cell from one of viewcontroller to have a prsent modal view "full screen" it's not working ,how can i fix that
as you have added all the viewcontroller as a subview you don't need to present it
you just try
[self.view bringsubviewtofront:a.view];
hope this help ,
EDIT
use following local notification calling methods to solve your problem,
//place in class from which you want to perform action
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(openLarge:)name:#"openLarge" object:nil];
//place in class where you want to perform action
[[NSNotificationCenter defaultCenter] postNotificationName:#"openLarge"
object:nil userInfo:nameDict];
regards,

Iphone web application problem on iphone keyboard open

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.

Iphone- How to resize view when call status bar is toggled?

I'm creating an iphone app with few elements inside the controller (e.g tab bar, uiview, uitoolbar, etc..). Everything works fine until I encountered this problem. While my application is launched, I received a call and it shows the "Call Status Bar" which ruined the ui. Some elements are pushed down because the "Call Status Bar" is taking space at the top.
Anybody here have an idea on how to fix this issue? I'm new to iPhone app development.
Your reply is greatly appreciated...
Best Regards,
dianz's solutio works just fine but is a bit redundant if you are only interested in knowing about the notification inside of a specific view controller.
After the delegate method application:didChangeStatusBarFrame: is called in the Application Delegate UIApplicationDidChangeStatusBarFrameNotification is posted through [NSNotificationCenter defaultCenter].
Instead of using the delegate method application:didChangeStatusBarFrame: to simply repost a custom notification you can add an observer to UIApplicationDidChangeStatusBarFrameNotification directly from your view controller.
In MyCustomViewController you would add something similar to this:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(doSomething:)
UIApplicationDidChangeStatusBarFrameNotification
object:nil];
Now you no longer need to define the application:didChangeStatusBarFrame: delegate method in appDelegate (unless you plan to do something in the appDelegate when the status bar changes size).
As with dianz's example you need to remove the observer in dealloc
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
You should put this function on appDelegate, this will trigger when the status bar change
- (void)application:(UIApplication *)application didChangeStatusBarFrame (CGRect)oldStatusBarFrame
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
[dict setObject:#"trigger" forKey:#"frame"];
[[NSNotificationCenter defaultCenter] postNotificationName:#"trigger" object:self userInfo:dict];
}
This Code will send Notification with the name "trigger"
Place a code to your view Controller (e.g: viewDidLoad, etc..) this listen if there are notification send with a name "trigger"
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(dataReceived:)
name:#"trigger"
object:nil];
And create a function dataReceived:
- (void)dataReceivedNotification:(NSNotification *)notification {
NSDictionary *data = [notification userInfo];
// do something with data
}
do something on this part of the code, maybe you change the frame of your tab bar, uiview frame, toolbar frame
And in dealloc, put this code to remove the observer
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
Basically what you normally do is try to set up the autoresize flags of all your ui elements in interface builder so that when the main view is "squashed" by the call status bar everything will still look reasonable. It's a little hard to explain how to do all of this in one message, but I recommend creating a view in IB, placing some subviews in it, then resizing the main view while playing with the autoresize flags to get a feel for how the flags work. The autoresize flags are in Command-3 (size inspector).
You can also set wantsFullScreenLayout in the main view controller to YES to cause the view to take up the whole screen, including the area under the status bar, but then you'll have to make sure not to place anything under the status bar and the call status bar will overlap anything too close to it, of course.
for me, whenever the status bar is enlarged, the -(void)viewWillLayoutSubviews is always called. This is perfect for me because all my subview setFrame code is in this function.