简体   繁体   中英

MPMoviePlayerViewController Status bar not hiding

hello i am working on a App which play video in an Application and i have used following code -

MPMoviePlayerViewController *theMovie=
[[MPMoviePlayerViewController alloc] initWithContentURL: myurl];
theMovie.moviePlayer.repeatMode=MPMovieRepeatModeOne;
theMovie.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
[theMovie.moviePlayer play];
[self.view addSubview:theMovie.view];

but i want to remove this status bar from the Video controller please see the attach file. 在此处输入图片说明

try this code,

ViewDidLoad Method:

    float delay = 0.1;

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC),  dispatch_get_main_queue(), ^{
    [UIApplication sharedApplication].statusBarHidden = NO;

ViewWillAppear method give this below Code:

[UIApplication sharedApplication].statusBarHidden = NO;

hope its helpful

Add the following code to your view controller:

if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
    // iOS 7
    [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
} else {
    // iOS 6
    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}

- (BOOL)prefersStatusBarHidden {
    return YES;
}

or write this in appdelegate.m

[[UIApplication sharedApplication] setStatusBarHidden:YES];

Or add the property Status bar is initially hidden in your plist file

在此处输入图片说明

Folks, in iOS 7+

please add this to your info.plist file, It will make the difference :)

UIStatusBarHidden UIViewControllerBasedStatusBarAppearance

在此处输入图片说明

I don't know if apply for your case, but in my case the status bar appears after I loaded a UIImagePickerController and change my default screen orientation.

I fix this situation add application.statusBarHidden = YES; inside appDelegate like this:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
// Detect if I need to hide the StatusBar (optional)
if (iNeedToHide == YES) {  
    application.statusBarHidden = YES;
}
return UIInterfaceOrientationMaskLandscape;
}

i hope it will help you

in AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
application.statusBarHidden=YES;
}

or

use this code it will help you:

   [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
-(BOOL)prefersStatusBarHidden
{
return YES;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM