I'm having trouble displaying the Google AdMob test banner. I created a simple application as described in their docs https://developers.google.com/mobile-ads-sdk/docs/admob/ios/quick-start#manually_using_the_sdk_download. The only difference from that sample is that I'm using a UINavigationController
After looking around for a solution to another issue I found that by adding [self setEdgesForExtendedLayout:UIRectEdgeNone]; on my ViewController the banner appeared!
Has anyone run into this? What workarounds/fixes are there? Am I doing something wrong?
UPDATE 1
I created a sample project so you can see and test. I created Tags along the way to make it easy for you to navigate backwards as I made my changes. https://github.com/RoLYroLLs/GoogleAdMobTest.
One important thing to note is that as I made my changes, the ad doesn't appear when the label AND the textview were removed from the view (check tag v0.1.3. When I removed either one the ad did show up (check tags: v0.1.1 and v0.1.2).
In tag v0.1.5 I added [self setEdgesForExtendedLayout:UIRectEdgeNone] to make it work, but I don't like what it does to the tab bar and the navigation bar, they look darker or something.
Any feedback is welcome. Thanks!
UPDATE 2
The issue seems to be fixed when using Xcode 6.0.1. I guess it was a bug in Xcode 5.x.x?
You have to setup the proper auto layout constraints so when the view shifts behind the navigation bar, the banner adjusts itself.
The banner should have the following constraints:
leading space to superview
trailing space to superview
top space to top layout guide
The tableView should have the following constraints
vertical spacing to admob banner
leading space to superview
trailing space to superview
bottom space to bottom layout guide
You can set the constraints visually in the storyboard.
This looks like it was a bug in Xcode 5.x.x as I just upgraded to Xcode 6.0.1 and it works just fine.
Related
I have a problem with my code. My application displays within iOS safe area layout guide, however I'd like to force it to display "outside". I have searched the internet and unfortunately I found only "reverse" problems. I don't use interface builder, all my views I create programmatically. I have a main view controller which starts up automatically with the app and from here I start creating all my stuff. My interface builder just shows this view controller and a view assigned to it. Interestingly, the view appears to be really full screen when viewed in IB.
Yes, I tried turning on/off the "Use Safe Area Layout Guide" option for the view. Also I tried to use topLayoutGuide and bottomLayout guide instead and constrain the main view to them, but it still fails:
- (void)viewDidLoad {
[super viewDidLoad];
UILayoutGuide *margins = self.view.safeAreaLayoutGuide;
[NSLayoutConstraint activateConstraints:#[[self.view.topAnchor constraintEqualToAnchor:self.topLayoutGuide.topAnchor],
[self.view.bottomAnchor constraintEqualToAnchor:self.bottomLayoutGuide.bottomAnchor]
]];
//...
}
This is what I see in the IB:
1) view
2) safe area - I can't get rid of it in any way:
3) result (simulator / real device):
I also did RTFM but a) I'm stupid, b) I'm too tired, c) both
Any help would be appreciated :)
If you use constraints on the view, it will usually automatically align to the safe area. You can override this and have it constrain to the superview instead by clicking the little arrow to the right for a drop down menu:
You then select "View" instead of "Safe Area". Also make sure to un-click "Constrain to margins" or it still won't fill out the whole screen.
I resolved my issue. The application was not displaying in full screen because of missing launch image in my assets for iPhone XR. Because of this iOS was falling back to the closest launch image keeping aspect ratio, thus defining the application size.
The second issue (not loading the image, displaying some default splash screen insead) - removing the app from device and installing from scratch helped.
Thanks everyone involved :)
I am refactoring some views in my application regarding iPhone X constraints and moved a group of views into a TabBarController view with also a Navigation views. Everything working just fine but one thing. Well... There is always that "one issue left" thing, isn't?
So the issue that I have is that the Top Layout Guide is set high. And I don't want that. See screenshot about this issue.
I have set the top constraint of the labels "Maandag" and "Op afspraak" (top one) to 0. Well to the Top Layout Guide. All views that I converted to this TabBar view has this issue :( I am using Storyboards.
This is the result on device (same on all kind of devices)
Thanks in advance!
With iOS 11, Apple is deprecating top(bottom)LayoutGuide and switching to the safeAreaLayoutGuide. In code, you could pin your view using view.safeAreaLayoutGuide.topAnchor, but in storyboards you'll want to pin stuff to the safe area node inside your view controller's view:
This must be just another autolayout question. I did do all I can think of to find out what is wrong but nothing seems to right. Maybe I'm missing something or doing something really stupid.
I added an UIImageView to a ViewController, set the autolayout constraints of the ImageView in Xcode. To see the borders, i added an IBOutlet to viewcontroller and set border width of Image to 2.0 and border color to red. It works well in iOS 6, in both landscape and portrait mode. When i run the same in iOS 7, the bottom part of the view goes under tab bar.. heavy sigh. Im hoping this is something configurable in the UI, rather than making code change. I unchecked "Unchecked" Adjust scroll view insets for ViewController , also made sure that the bottom Space ( Vertical Space) of the ImageView is set to the top of Botton Layout Guide, as mentioned in apple ios migration guide. Im not sure what else to do and im not feeling lucky. Can someone please take a look ? I already spent few days on this and im not reaching anywhere. Here are few screen shots if it helps.
Thank you for your time.
Unfortunately stackoverflow wont let me add images unless i have brownie points :(
hopefully these links would work
iOS 7 screenshot
iOS 6 Screenshot
There is an option I believe called 'under bottom bars' uncheck this and it should work.
I found this code in another post and it resolved my issue.
- (UIRectEdge)edgesForExtendedLayout {
return [super edgesForExtendedLayout] ^ UIRectEdgeBottom;
}
I've seen similar questions about custom transitions(iOS7 Custom ViewController transition and Top Layout Guide and Navigation controller top layout guide not honored with custom transition), but I have problem even with regular push. I'm using latest Xcode available now (Version 5.1.1 (5B1008)).
Here is my storyboard:
Problem occurs in 3rd VC
Here is 3rd VC settings:
My 3rd controller's layout is follows:
UIView
UIScrollView
InnerUIView
Other views
I've tried two different ways to create a layout:
Ignore top layout guide (it has y = 64 because of nav bar)
I pinned scrollview's top to container (ignoring topLayoutGuide), manually set height of inner view and pinned its top to scrollView. It gave me the following result:
Looks fine, but why do I need top layout guide then?
Use topLayout guide
ScrollView's top is pinned to topLayoutGuide.
As you can see, top button moved down and view looks strange.
What is the right way of creating such layouts?
I had the same problem and spent hours pulling my hair out.
My container view inside scrollview had weird top offset despite the fact that it had top constraint set.
The workaround I've found - you have to uncheck Adjust Scroll View Insets in your controller layout options
that way content view (in my case) stays pinned to scrollview's top.
Unfortunately I couldn't find any reasonable explanation of this behaviour.
In my case, Xcode 7 and 8, I had to uncheck the 'Adjust Scroll View Insets' for the Views in my Navigation View Controller. And yes, it wasted too much time before I figured this out.
EDIT: Apple has found out that we have found a solution, so they managed to break this again in XCode 9 and 10, to keep us developers pulling our hair. Haven't found a solution yet.
I hate iOS scroll views with auto layout, they are driving me crazy!:-D
I have found a method which works perfectly on iOS 7 to use scroll views:
I put the scroll view directly in the main view, attaching the scroll view to the edges of the super view(top,bottom leading and trailing space equals to 0).
Then I put a UIView into the scroll view attached to the edges of the scroll view, (top,bottom leading and trailing space equals to 0).
Then I set the height constraint of the most internal view, I link it at my ViewController class, and I modify its value programmatically.
Or, if the view it's 'static' I put every component using the storyboard into the internal UIView, starting with the one at the Top attached to the top of the super view, the one under, attached with the constraint 'Vertical Spacing' referred to the one over him..and so on... Until the last, which is also attached to the bottom of the UIView..
Everything works fine in iOS 7, it's perfect, but iOS 6 is messing around with the constraint.
When I first launch the view everything is perfect, but it seems to recalculate the constraints even on the didappear(and in a bad way), in fact, if I leave my view while it's scrolled down, when I come back to it(let's say we are in a navigation controller) , is like it's everything 'moved up' and the components at the top are hidden.
Is there a way to make scroll views work in both iOS 6 and iOS 7, I'n thinking at two storyboards as the only solution, please tell me there is another way... :-)
thanks everyone, I post two images explaining my problem, taken from the top of the screen:
Well uncheck use AutoLayout in file inspector and try.