Capture MKMapView screenshot different in iOS 5 and iOS 6? - iphone

I would like to get screenshot of mapview. So i used following code. This code works perfectly in ipad and simulator but not on ipod. The iPad has iOS 6.0 and my xcode is 4.2.1 and the iPod has iOS 5.0.
- (UIImage*) renderToImage
{
UIGraphicsBeginImageContext(mapView.frame.size);
[mapView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return viewImage;
}
The problem is, i have got same image in iPad, iPod ans simulator but not names corresponding manual screen capture and programatic screen capture.The names are very big in iPod, at the same time names are normal in iPad and simulator and also some names are invisible in iPod.That is the my problem.
The following images are:
This image belongs to iPod manual screen capture.
This image belongs to iPod programatic screen capture.
I don't know where the problem is. Please help me anyone.

The problem is UIGraphicsBeginImageContext(mapView.frame.size); here. I have just replaced this to UIGraphicsBeginImageContextWithOptions(mapView.frame.size, NO, 0.0);. Then it is working in iOS 5.0.

You can tell by looking at the app in each situation, it's not your screenshot code that is magically creating different maps, the underlying maps are different.

Related

iPhone5 and iOS6 combination creates display issues

My cocos2D app, Forever Afloat, works perfectly fine with all the combinations until you get to iPhone 5 and iOS6!
The app display is all stretched out so that you see only the lower left corner and the rest is off the screen.
Only until you force it to autorotate, does the app begin to display at proper dimensions...
My problems can also be found at this problem cocos2D iOS 6 retina display
They asked the same question.
Any solutions?
Thanks!
cocos2d uses image with image-hd.png and not image#2x.png
Check whether you are using #2x an replace by hd
Use new version of cocos2d and here is image extension.
-wide.png for iphone 5
-widehd.png for iPhone 5 HD
-hd.png for iPhone HD
-ipad.png for iPad.
-ipadhd.png for iPad HD.
There were some issues within the AppDelegate regarding the order of calls that made the display all strange. All I did was move the initalization method to the top and it fixed everything!

Image memory issues in iphone retina display

I am developing a game for a company. Right now we are coming across a problem.
Our game is made for the iphone and ipad. We have both regular images and #2x images. Our game works perfectly fine on iphone 3gs and all the ipad versions. But our game crashes on iphone 4 and 4s.
Is it crashing because its retina? I know all the images are 4x.
We are now wondering what kind of ways it can crash.
Can anyone help me out here?
EDIT:
our game uses UIKit, cocos2d and uses OpenGL
So do this: in Xcode uncheck all #2x images - so imageNamed will only find the normal images. Run the app. does it crash? If so then its not the images. Now start turning on the #2x images - a few at at time. Run it. does it crash?
If you have a slew of #2x retina images for retina iPad, yea, might be a problem. You don't say how many images you are using - if hundreds yeah, don't use imageName. I use a small amount and have no problems iPad/iPhone.
How do you load images into imageviews? if you use [UIImage imageNamed:#"blablabla.png"] - that's evil - look here why. Use this instead:
[UIImage imageWithContentsOfFile:[NSString stringWithFormat:#"%#/name_of_image.png", [[NSBundle mainBundle] resourcePath]]].
ALWAYS.
EDIT: adjust the above image name to include #2x when you are loading retina sized images.

Use different icons for iphone 3gs & iphone 4 / 4s

I have icons inside my application for uibutton & on uitable cell. Lets say I have image named "sampleImage.png". Can my app use the image named "sampleImage#2x.png iphone with retina display automatically provide it is in my app bundle ?
If yes how can write code for it because I have code like
cell.imageview.image = [UIImage named:#"sampleImage.png"];
Does it work even if I hardcoded the image name?
Any kind of help is appreciated.Thanks
Yes, UIImage will automatically use the #2x version of an image on a retina display.
Searching for an answer of your question I came across this: what is the code to detect whether ios app running in iPhone, iPhone Retina display, or iPad?
One of the answers mentions this:
There's often no need to determine directly whether you're on a retina display because UIImage handles that automatically when you use imageNamed and append "#2x" to your high resolution image file names (see Supporting High-Resolution Screens in the Drawing and Printing Guide for iOS).

cocos2D from iPhone to iPad

I'm developing a game using cocos2d. It's running now on iPhone and also supports Retina display. With retina i'm using images with "-hd" postfix. Now i want my application to be able to work on iPad using this images. How can i do that ?
PS: I don't have a real iPad and can only use a simulator. I will test the game on my friend's iPad after it will work well on a simulator. Is it possible to use hi-res images with simulator and how to do it?
I'm using cocos2D 0.99.5
inside CCFileUtils.m
inside method name +(NSString*) getDoubleResolutionImage:(NSString*)path
edit if( CC_CONTENT_SCALE_FACTOR() == 2)
to if( CC_CONTENT_SCALE_FACTOR() == 2 || (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad))
this will make the app to load the -hd image when running on ipad, remember to change your app targeted device family to iPhone/iPad.
this will solve the loading of -hd problem for ipad.
but after loading -hd file for ipad resolution, you will also notice that most of your image position should be off alignment, now either you go directly into the cocos2d folder to edit how CCNode,CCSprite,CClabel handle the positioning of thing or you code it in your code checking if its ipad or not.
if you are using CCSpriteBatchNote. this will also cause another problem because you will be reading from the -hd SpriteSheet. so the texture Rect u set to cut need to be double too.
another method is position everything according to winsize. i haven try this method.
I don't exactly understand the question but I will try to answer.
You can technically use the same graphics for the iPad, but they will not look as nice. For one, they will all blurry and pixelated, and two, the iPad has a different screen aspect ratio that the iPhone/iPod Touch. If you do make separate images for an iPad version of your game, it will not be extremely difficult to do. If you want to do this, I suggest posting a new question.

Will my iphone 3gs app work ok on iphone 4?

So I'm currently making an app that supports both iphone 3gs and ipad (this is a universal binary app).
What I'm wondering is how will iphone 4 users view my app, will they see it pixelated? will they not see it full screen since my iphone 3gs is on a smaller resolution?
I don't have an iphone 4 yet but I'd rather just release this app as is - just for 3gs and ipad. Is there anything that I must know / any precautions etc? Oh (i just thought of this) is there an iphone 4.0 simulator so i can check out if my app works okay?
Thanks!
Basically any bitmap graphics (PNG files) will look a little blurry on the iPhone 4's Retina display.
The easiest way to fix this is to make double scaled versions (100x100 becomes 200x200) of all your PNG files and add them to your project suffixed with "#2x.png". In other words, MyBitmap.png will become MyBitmap#2x.png. Luckily your code doesn't have to change. On the iPhone 4 the OS will automatically choose a #2x.png instead of the regular one when you do:
UIImage *myBitmap = [UIImage imageNamed:#”MyBitmap.png”];
Xib files will also use the #2x.png if there is one available.
Other than that there's also launch images and Application Icons to worry about. This blog has a good summary.
Yes you can change your device type, by in the simulator pressing: Hardware->Device->iPhone 4 If you don't have it you might want download the latest devevloper tools.
Also you might have to press Window->Scale->100%