Reputation: 217
-(BOOL)prefersStatusBarHidden
{
return YES;
}
- (IBAction)PhotoImportAction:(id)sender
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = NO;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone)
[self presentViewController:picker animated:YES completion:nil];
else
{
popover=[[UIPopoverController alloc]initWithContentViewController:picker];
popover.delegate=self;
[popover presentPopoverFromRect:PhotoImportButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *selectedImage=info[UIImagePickerControllerOriginalImage];
VisualEffectImageVIew.image=selectedImage;
BackgroundImageView.image=selectedImage;
ForegroundImageView.image=selectedImage;
if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone)
{
[picker dismissViewControllerAnimated:YES completion:nil];
}
else
{
[popover dismissPopoverAnimated:YES];
}
}
-(void)viewWillAppear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
Above code is pretty straightforward, everything works fine ,except viewWillAppear
method that doesn't work on iPad after dismissal of UIPopoverController
, so we tried using popoverControllerDidDismissPopover
method but the statusBar is still visible. Any solution is appreciated.
Upvotes: 1
Views: 179
Reputation: 217
According to apple's documentation the method popoverControllerDidDismissPopover will not be called if popoverController is dismissed programatically.You can manually call the popoverControllerDidDismissPopover method.
[self popoverControllerDidDismissPopover:popoverController];
Upvotes: 1
Reputation: 3960
From your code what I see is you have not set UIPopoverController's delegate
.
add following line
popover.delegate = self
before presenting the popover. Hope this works.
Upvotes: 1
Reputation: 676
You didn't set the delegates of the popover. Please set it and check if delegate method is working or not...
Hope it helps :)
Upvotes: 0
Reputation: 1327
Add following line in viewdidload
[[UIApplication sharedApplication] setStatusBarHidden:YES
withAnimation:UIStatusBarAnimationFade];
and add new method
- (BOOL)prefersStatusBarHidden {
return YES;
}
also change info.plist file View controller-based status bar appearance" = NO
Upvotes: 0