How to resize iAds banner in IOS 4.2 - objective-c

Can we resize the iAds banner frame like (200,50). Verified all properties of AddBanner View. its having only ADBannerContentSizeIdentifierPortrait and ADBannerContentSizeIdentifierLandscape, But not having any frame adjusting property. My requirement like in iPad i need to split the view explicitly with out using SplitViewController. their my iAds taking complete full size of (768,66), But requested is (460,66). So how t achieve this requirement. please provide solution for this.
TIA.

Use adView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleRightMargin;
Also check http://useyourloaf.com/blog/2010/11/27/iad-framework-updates-for-ios-42.html link its use for you.

Related

UIImageView off screen in landscape mode

I am using iOS7 and I have a UIViewController with a UIImageView that fill the screen in Aspect Fit mode.
In portrait mode the image looks good but in landscape mode the image is off screen.
Can anyone help me?
Thanks ;-)
As you can see the image is in the same position in both orientations. It's the same distance away from the top panel and pushed up against the left side of the screen. iOS doesn't automatically change the frame of the image for you when you change orientations. You have to either do it programmatically or use auto layouts to achieve the display you want.
AutoLayout Guide
Autolayout is a pain to learn at first but stick with it. It's a great solution when you get the hang of constraints and start modifying them programatically. In fact it's recommended you never set the frame explicitly, you should always use constraints to position and size frames.
As Literphor mentioned above. it is layout issue. Either use autolayout or do the trial and error (because you are not familiar with Autosizing) with settings shown in below image. That should fix the issue.
self.imageView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin |
UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
You must "play" with autoresizingMask

iOS 7 + Auto Layout: Strange UIImageView behaviour

I've got a strange UIImageView behaviour:
I've got a UIViewController with an embedded UIImageView and a close button. Very basic stuff, done a thousand times. I didn't use Auto Layout that much in the past, but another view controller in the same Storyboard has nearly the same config and doesn't appear as strange as this specific one.
In my Storyboard the Controller looks like that:
...and on the device it looks like that:
That image is 1024x768, so it should be filled to the bounds. Content mode in the image view is Aspect fill. When i dismiss the view, i can see that the upper part of the image view must be hidden at the top with some negative Y or something.
I need Auto Layout in this storyboard, because it's an iPhone + iPad App with both orientations.
Has someone hat a behaviour like that before?
Thank you!
Edit:
Here is the layout panel:
First, get rid of the alignment constraints, they are not needed if you're already anchoring your view to every side with a set distance.
Second, check the mode property of your UIImageView in the interface builder. If the image was not big enough and you had it set for "TOP" instead of, say, "aspect fill", you'd see something like this even though the view is actually covering the whole screen.
I'm sorry that I have to say this, but it was, as you certainly thought, my own fault.
The problem was that I made a photo with the iPad, and the iPad can be used in both orientations in this app. The photo was taken and was then used for an own view that allows the user to put annotations on the image.
The image gets then saved, and that was were the problem occured: I call
UIGraphicsBeginImageContextWithOptions(self.view.frame.size, NO, 0.0);
The landscape image was now taken into a portrait frame. After adjusting this and only allowing portrait mode, everything worked well.
Thanks anyways for your answers. And sorry for asking a question when the problem was another one and my own fault.

Autolayout is not resizing Uicollectionviewcell items when animating between layouts

I have a uicollectionview cell with an image view inside that I want to resize when I switch to a larger 'zoomed in' layout.
I have placed constraints inside the cell that does resize the image view when the zoomed in layout is displayed. I am using uicollectionview setLayout animated method.
The problem is the image does not scale with animation only the collection view cell does.
The image seems to just jump into its end size with no interpolation. So the animation looks extremely choppy.
It seems as if I need to somehow control the auto layout constraints so they animate with the set layout animated method but I don't know how.
Is there a proper way to scale the cell and it's contents ?
Thanks so much!
I had (have) the same problem with Auto Layout!
Presently the simplest way I've found to deal with it is to set:
imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
This causes the imageView size transition to be animated smoothly and is the only thing that I've found to work consistently with setCollectionViewLayout:animated:
You may find this answer and the linked GitHub demo app I wrote to solve a similar issue helpful.

Wanna Scale up contents inside the view according the size of the view, which chages according to the device

I share same storyboard for iPad and iPhone. I have contents inside a small view. I Wanna Scale up contents inside that view according the size of the view, which changes according to the device it's been installed.
try to set autoresizing masks like
[YourView setAutoresizingMask:UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
Hope will help this

Rotating MapView according to compass

I'm working on Map application that needs to work like original MapView on iOS.
I need to rotate mapview according to compass heading value. I tried MTLocation example also I also tried this answer But my results is not good.
Please see the screen shot.
When I rotate mapview according to heading value Map is rotating but as you can see on screen tiles is missing.
How can I solve this display problem ?
Regards
- Fatih
Hy,
I'm the author of MTLocation. Thanks for using it by the way!
For this to work you have to make sure, that your MKMapView is a subview of your ViewController's view (and not the view itself). Then you have to increase the frame of your mapView with a simple Pytaghoras - calculation: the width and height must be at least as big as the diagonal: sqrt(visibleWidth[320]^2 + visibleHeight[480-88]^2) = 506.
So that means
mapView = [[MKMapView alloc] initWithFrame:CGRectMake(-100,-100,520,520)];
Hope that helped, please consider upvoting if it fixed your problem.
You can consider using a bigger frame for the MKMapView object. It should probably be a square with each side equal to the length of the device's diagonal. The problem with this approach is that there are regions of this object that the user won't see but we process information like views for annotations related to that region anyway. Other properties like visibleMapRect would be least helpful.
Another alternative would be to be zoom in by scaling the MKMapView object on rotation. But this might make the map blurry (untested). You could zoom out on the region displayed in the map but it could lead to frequent refreshes. You can look at a middle ground where you don't zoom out until the map is rotated over a certain angle. You can also look at using two views where one of the views is off screen and updated so that it can replace the view after a certain amount of rotation so that it feels seamless.
I am working towards making my own maps application in iPhone. I want my maps to rotate as the user turns. I tried setUserTrackingMode available in iOS 5, but due to some reason it doesn't work. So I decided to take help of MTLocation framework here.
Till now I have done the following.
created a new project and copied all .m and .h files in that.
Import MapKit.h and MTLocation.h.
In Viewcontroller.h, defined property for mapView (should I define a property for locateMeItem).
In ViewDidLoad, paste the code given at the end of the page here.
I get a few errors:
Can't see the locateMe button when created programatically.
Undefined property headingEnabled.
myCustomSelector has no effect.
self.toolbar- toolbar is not a instance of ViewController.
I have tried a code at gist[dot]github[dot]com/1373050 too, but I get similar errors.
Can anybody explain a detailed procedure of this.