Labels do not appear in Mac Retina devices - objective-c

I received couple of screenshots from a user indicating that the CCMenuItemFont and CCLabelTTF do not appear on a Macbook retina device. All the images in the application are correctly shown while the text doesn't appear correctly.
A code sample of one of the labels:
CCLabelTTF *label=[CCLabelTTF labelWithString:answer fontName:#"Helvetica" fontSize:30];
[label setColor:ccc3(255, 255, 255)];
[label setPosition:ANSWER_POSITION];
[self addChild:label];
I am using two languages in the application. The english words appear as a small wave while the others don't appear at all. A screenshot to show an english word:
Unfortunately, I don't have access to a Retina device, and the following method is not working for me to debug the problem: How to simulate a retina display (HiDPI mode) in Mac OS X 10.8 Mountain Lion on a non-retina display?
Any ideas how to solve this problem?
Thanks in advance

The problem was in the version of cocos2d that I was using (2.0V). Either use 2.1 or apply the solution mentioned in this link:
Solution
The solution that worked correctly for both languages was adding the following line in CCTexture2D:
[[NSAffineTransform transform] set];

Related

How to get off transparency of my imageView?

I am using an ImageView.
Having a picture inside, working well as aspected with 10.9 sdk.
[_myImageView setImage:myImage];
Since 10.10 sdk the picture has transparency. (10.11 too)
Has anyone a hint of the common way to get the transparency out of the picture?
Thank you!

SpriteKit iOS8 different physical behavior

i've noticed different behaviors in Physics, for example:
I have coded a rope with many SKSpriteNode and SKPhysicsJointLimit for the chain.
At the ends i've attached two SKPhysicsJointSpring to two physics-disabled SKSpriteNode.
On iOS7 it works like a charm, in iOS8 there are some "distorsion" on the rope.
These are the pics, the little square is just a joint for touch and the big rectangle is just a trigger.
In iOS8 you can see a "U" distorsion around the candy, but not in iOS7. Why?
iOS7 Launcher http://i.imgur.com/yRt6UfB
iOS8 Launcher http://i.imgur.com/WE3Esuu
The right PhysicsJoint for a rope is SKPhysicsJointPin and not SKPhysicsJointLimit.
This solution works well in iOS7 and iOS8.
I also had some serious troubles with ios8 physics behabiour... But for th e rope problem mybe you can checkout my code from this answer. It runs the same on ios7 and ios8
https://stackoverflow.com/a/20855093/3148874

different background images for landscape and portrait view

I am developing an universal app where I have given a background image for a UIView using the following code.
UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"backImage.png"];
[self.view addSubview:imgView];
[self.view sendSubviewToBack:imgView];
I have created the following images and added to the project,
backImage.png
backImage#2x.png
backImage-Portrait~ipad.png
backImage-Portrait#2x~ipad.png
backImage-Landscape~ipad.png
backImage-Landscape#2x~ipad.png
But it does not seem to take the correct images.
It works fine when I run the app on iphone (I mean it takes the backImage.png and backImage#2x.png accordingly) but when I run the app on ipad it does not use the ipad images, it still uses the iphone images.
Can anyone please tell what must be going wrong.
Thanks in advance.
You need to detect in your code what type of device is being used, and depending on that, choose the appropriate image.
See here: iOS detect if user is on an iPad
I may be wrong, but I don’t think UIImage will know whether to load the ‘portrait' or ‘landscape' version of an image, much less change them dynamically when you rotate your interface. I think you’re expecting a lot more magic then there is.
Those conventions work in the app launch snapshot, but I think that’s the extent of it?

UIButton setImage behavior different in iOS6 sim vs iOS6 device?

I set different images for my UIButtons, like so:
[testButton setFrame:CGRectMake(0.0f, 416.0f, 64.0f, 64.0f)];
[testButton setImage:[UIImage imageNamed:#"test.png"] forState:UIControlStateNormal];
(The various images have different dimensions to which I re-size the UIButtons)
This works as expected in iPhone 6.0 simulator, but the images are not displayed on the buttons in an actual iOS 6.0 iPhone; the buttons are invisibly there with correct dimensions locations.
I want the same button behavior on the iPhone device; how to proceed?
Ha ha! SIGH Of course, the filenames were mis-named. Took 2 days to figure that out :(

-[NSString sizeWithFont:] returns different results in release and debug builds [duplicate]

This question already has answers here:
App Store code runs different from Xcode/Device code on iPhone 3G
(4 answers)
Closed 2 years ago.
I've used this code to resize a UILabel's frame height to fit dynamic text several times with success:
(...)
CGSize labelSize = [thelabel.text sizeWithFont:font constrainedToSize:constraintSize lineBreakMode:UILineBreakModeWordWrap];
All was well until I started to build my apps using the iOS5 SDK.
For armv6 devices (iPhone3G/-), when building for debug, the label size is okay, but when building for release, the height value retrieved is the same as the width. I am running both of these builds on an actual device.
example with following log line:
NSLog(#"labelSize: %f %f", labelSize.width, labelSize.height);
output:
iphone3G - debug >
Thu Nov 3 18:22:50 unknown appname[1071] : labelSize: 115.000000 19.000000
iphone3G - release >
Thu Nov 3 18:22:50 unknown appname[1071] : labelSize: 115.000000 115.000000
Can anyone help or provide me with another solution to adjusting UILabel's height based on the text length?
I'm aware there are some similar questions about this method, but they do not address this particular issue.
Had the same issue.
If you follow the link supplied by vfonseca, you arrive at: Is there a way to compile for ARM rather than Thumb in Xcode 4?
And the selected answer tells you how to add the correct compiler flags to prevent this. Alternatively upgrade to Xcode 4.3 which has fixed this bug.
I still haven't managed to understand the problem.
Although, replaced the UILabel resize method with an alternative way:
//init and store initial rect
CGRect initialLabelRect = CGRectMake(2*kMargin, auxHeight , 200, 0 /*will be overriden*/);
UILabel *dataLabel = [[UILabel alloc] initWithFrame:initialLabelRect];
dataLabel.text = #"long text here";
[dataLabel setFont:[UIFont fontWithName:#"Arial-BoldMT" size:15]];
//fit size will adjust both width and height, but i'll be discarding the width
[dataLabel sizeToFit];
//set the new frame (initial, but with the computed height)
dataLabel.frame = CGRectMake(initialLabelRect.origin.x, initialLabelRect.origin.y, initialLabelRect.size.width, dataLabel.frame.size.height);
//add and release
[superview addSubview:dataLabel];
[dataLabel release];
So, the issue persists, but, for the time being... I'm replacing the code occurrences for this approach.
If someone come up with a clue about what happened, please let me know. I'm guessing it+s a bug on sizeWithFont method... but is always easier to blame on the SDK when we can't understand... :)
Thank you all. Cheers.
I've discovered a difference in what sizeWithFont:constrainedToSize:lineBreakMode: will return depending on which architecture your code is running on. I've used the function to calculate the height of strings I want to display in UILabels in UITableViewCells so that I can calculate the final height of the cell. I was getting one size on my iPhone 4, and a tester was getting big large cells on their iPod (old armv6 device).
The solution was posted here: Is there a way to compile for ARM rather than Thumb in Xcode 4?
I'm sure the optimization fix described below works as well, but disabling thumb might allow you to maintain your optimization settings? I don't know, you'd have to test this.