I'm trying to make an overlay on the camera mode on iPad. when the camera is in landscape mode, the overlay only covers 2/3 of the screen instead of the full screen. It is covering the whole screen in portrait mode however. My guess is the overlay could possibly be only showing in portrait size so that the overlay doesn't appear to be covering the full screen.
UIView *overlay = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
overlay.backgroundColor = [UIColor blueColor];
overlay.alpha = 0.3;
overlay.opaque = NO;
imagePicker.mediaTypes = mediaTypes;
imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
imagePicker.modalPresentationStyle = UIModalPresentationFullScreen;
imagePicker.cameraOverlayView = overlay;
However can i make it to cover the whole screen? Any help will be appreciated.
Do manual setting for view frame. when it rotate to Portrait or Landscape.
For Portrait
CGRectMake(0,0,768,1024);
For Landscape
CGRectMake(0,0,1024,768);
Related
In my project on Objective-C mainScreen with Custom NavigationBar (created from code):
mainNavigationController = [[NavigationController alloc] initWithRootViewController:mainMenuViewController];
mainNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
mainNavigationController.delegate = self;
mainNavigationController.navigationBar.tintColor = [UIColor whiteColor];
UIWindow* window = self.window;
window.backgroundColor = [UIColor whiteColor];
window.rootViewController = mainNavigationController;
[window makeKeyAndVisible];
I change self.view like size [UIScreen mainScreen].applicationFrame]:
UIView* mainView = [[[MainViewControllerView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame] autorelease];
self.view = mainView;
In mainScreenView I add scrollView:
scrollView = [[UIScrollView alloc] initWithFrame:self.bounds];
scrollView.autoresizesSubviews = YES;
scrollView.autoresizingMask = UIViewAutoresizingNone;
scrollView.backgroundColor = [UIColor clearColor];
scrollView.bounces = NO;
And add some subView inside scrollView:
[scrollView addSubview:myLogoView];
[scrollView addSubview:littleScrollView];
[scrollView addSubview:firstButton];
[scrollView addSubview:secondButton];
[scrollView addSubview:thirdButton];
[scrollView addSubview:fouthButton];
[scrollView addSubview:fifthButton];
[scrollView addSubview:sixthButton];
[scrollView addSubview:seventhButton];
[scrollView addSubview:activityIndicatorView];
https://www.dropbox.com/s/ttrkolgnch80kr9/safeArea.png?dl=0
If use XCODE 8 and iOS <= 10, all view place correct on mainScreen (myLogoView place ignore size of custom NavigationBar and have coordinate Y == 20.0 in absolute value coordinates of device screen),
but if use XCode 9 and iOS 11 myLogoView have place under my custom navigationBar (height == 44) myLogoView Y == 64.0 in absolute value coordinates of device screen, in iOS 10 (under xCode9) all working good - added view on mainScreen placed in start coordinates of screen and ignore height of custom NavigationBar.
In swift and storyboard I know how it fixed in iOS11 easy remove safeArea top line, but how remove safeArea from code in Objective-C.
How fix this trouble?
Safe area in iOS 11 is replacement of top & bottom layout and apple provide more detail on this like below :
The layout guide representing the portion of your view that is
unobscured by bars and other content. In iOS 11, Apple is deprecating
the top and bottom layout guides and replacing them with a single safe
area layout guide.
So base on this now top & bottom layout replaced with single safe area but agin if you are not using default NavigationBar so you can disable safe area in storyboard like below :
You can Uncheck safe area and it will revert to top & bottom layout.
Ref Before & After uncheck safe area:
Before or default :
Uncheck Safe area or old behavior :
Hope this will help to understand new iOS 11 update related to top & bottom layout and change your code as per this layout change.
Also here is one good blog to explain more on Safe area layout : Safe area
I'm trying to use Large Banner instead of Smart Banner but I can't make it stay at the bottom. I'm using this code for the smart banner and it stays at the bottom but doesn't work for the large banner. When I change from kGADAdSizeSmartBannerPortrait to kGADAdSizeLargeBanner, the banner moves to the top.
_bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
_bannerView_.frame = CGRectMake(0, self.view.frame.size.height - _bannerView_.frame.size.height , self.view.frame.size.width, _bannerView_.frame.size.height);
You can try with this code.
// Initialize the banner docked to the bottom of the screen.
// We start in a portrait orientation so use kGADAdSizeSmartBannerPortrait.
CGPoint origin = CGPointMake(0.0,
self.view.frame.size.height -
CGSizeFromGADAdSize(
kGADAdSizeSmartBannerPortrait).height);
_bannerView_ = [[[GADBannerView alloc]
initWithAdSize:kGADAdSizeSmartBannerPortrait
origin:origin] autorelease];
//Continue rest of initialization here
Reference : http://googleadsdeveloper.blogspot.in/2012/06/keeping-smart-banner-docked-to-bottom.html
I have a iPad application in Landscape orientation (iOS7), but when I present a UImagePickerViewController (Camera), this can be in portrait mode and need to avoid it.
Is there any way to lock this portrait orientation?
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage,nil];
imagePicker.allowsEditing = NO;
[self presentViewController:imagePicker animated:YES completion:NULL];
Thanks In advance.
Edit: I have followed the next iOS7 iPad Landscape only app, using UIImagePickerController and now the bars of the camera and preview picture taken appears in landscape mode, but if I take a photo with iPad in portrait orientation (app keeps on landscape orientation) the preview image rotates 90 degrees and 2 black sections appear on each side.
So, what I need is avoid this rotation in preview picture in the UIImagePickerViewController.
Does anyone have any idea?
I want to have a background image behind a UIScrollView area. That part's easy. The issue I'm running into is I don't want the image to move. I want it to fill the screen and then the scrolling just happens over that without effecting the image in anyway.
I've looked through lots of other postings on similar topics, but can't seem to get anything to work.
When I do the following, the background scrolls:
CGRect fullScreenRect = [[UIScreen mainScreen] applicationFrame];
UISCrollView *scrollView = [[UIScrollView alloc] initWithFrame:fullScreenRect];
scrollView.backgroundColor = [UIColor clearColor];
UIImageView *bkg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"img"]];
[scrollView addSubview:bkg];
Put the image in a UIImageView and place it behind the UIScrollView. Set the UIScrollView's color to 100% transparency ([UIColor clearColor]).
Is there any model view like this on the iPad?
Yes, there is:
UIModalPresentationFormSheet
The width and height of the presented view are smaller than those of the screen and the view is centered on the screen. If the device is in a landscape orientation and the keyboard is visible, the position of the view is adjusted upward so that the view remains visible. All uncovered areas are dimmed to prevent the user from interacting with them.
For example:
UIViewController *viewController = [[UIViewController alloc] init];
viewController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:viewController animated:YES];
viewController.view.superview.frame = CGRectMake(0, 0, 540, 500); // this is important to do this after presentModalView
viewController.view.superview.center = self.view.superview.center;