Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 7    Views: 561

Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
01/07/13 05:01 PM (13 years ago)

(solved) can't get Xcode to recognize 568h images for iPhone 5

This dilemma has been sucking up way too much of my time today - Up until this point I've managed to kind of cheat by using one 320X570 image which would work decently on both the 3.5 and 4 inch screens Well for the app that I'm working on that's just not gonna cut it, so I really need to figure this out. I saw the thread in which Mackimack explains how he did it using some classes found on github - http://www.buzztouch.com/forum/thread.php?tid=F3198ED9C6D34C9FE3A5DDF - If you look at that thread you will see that two people (plus me) could not get this method to work. I don't know what magic Mackimack conjured up to get it working, but if anybody else wants to try to download those classes and test it out, let me know if it works Besides that, I'm sure there is some code that could be added in somewhere to enable this - I found this example on github as well -- + (UIImage*)imageNamedForDevice:(NSString*)name { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { if (([UIScreen mainScreen].bounds.size.height * [UIScreen mainScreen].scale) >= 1136.0f) { //Check if is there a path extension or not if (name.pathExtension.length) { name = [name stringByReplacingOccurrencesOfString: [NSString stringWithFormat:@".%@", name.pathExtension] withString: [NSString stringWithFormat:@"-568h@2x.%@", name.pathExtension ] ]; } else { name = [name stringByAppendingString:@"-568h@2x"]; } //load the image e.g from disk or cache UIImage *image = [UIImage imageNamed: name ]; if (image) { //strange Bug in iOS, the image name have a "@2x" but the scale isn't 2.0f return [UIImage imageWithCGImage: image.CGImage scale:2.0f orientation:image.imageOrientation]; } } } return [UIImage imageNamed: name ]; } That might work if I had any idea at all where that code was supposed to go -- any help would be very appreciated
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
01/07/13 05:37 PM (13 years ago)
Well, somehow I've solved my own problem through random experimentation This is what worked for me - 1. Download the four files here - https://gist.github.com/3799648 2. Go to UIImageH568.m (NOT UIImage+H568.m) -- everywhere you see "imageNamed" simply delete the d off of the end so that it reads "imageName" (I figured this might be the issue because "imageNamed" never appears in BT_background_view.m, but "imageName" does) 3. Create three sized versions of the same image using the following name formats - image.png, [email protected], and [email protected] ---- image.png will be 320x480, [email protected] will be 640x960, and [email protected] will be 640x1136 4. Put the three images into your Xcode project 5. Go to your control panel -- set image.png as your small device background image and set scale/position to "Full Screen/Preserve Ratio" That should do it
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/07/13 06:26 PM (13 years ago)
I wanted to help, but I had no clue, lol! Glad you worked it out! Cheers! -- Smug
 
Cakebit
Code is Art
Profile
Posts: 502
Reg: Dec 15, 2010
In your local b...
16,520
like
01/07/13 07:03 PM (13 years ago)
Thank you for the information! This will be SUPER helpful! Glad you got it fixed :-)
 
ianJamesPiano
Code is Art
Profile
Posts: 2661
Reg: Feb 13, 2011
Palm Springs, C...
37,010
like
01/07/13 07:08 PM (13 years ago)
Great stuff Absentia, cheers!
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
01/08/13 12:59 AM (13 years ago)
the tutorial above works in the simulator but you have to make further changes for it to run on a device - follow these steps for the four files (taken from stackoverflow) REPLACE #import <objc/objc-runtime.h> WITH #import <objc/runtime.h> #import <objc/message.h> Then to get rid of the warning, you add these two lines in the header file of the involved class : #if (TARGET_OS_IPHONE) - (NSString *)className; + (NSString *)className; #endif And then in the implementation (.m) file : #if (TARGET_OS_IPHONE) - (NSString *)className { return [NSString stringWithUTF8String:class_getName([self class])]; } + (NSString *)className { return [NSString stringWithUTF8String:class_getName(self)]; } #endif
 
WebNevees
Code is Art
Profile
Posts: 206
Reg: Oct 28, 2012
KL
11,660
like
01/08/13 02:43 AM (13 years ago)
Hia, Just had a solution on it yesterday which worked for me. It's the same path but simplified a bit. http://www.buzztouch.com/forum/thread.php?tid=F3198ED9C6D34C9FE3A5DDF&fid=127FE84288EBDBCF646C715&sortColumn=FT.id&sortUpDown=&currentPage=1
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
01/08/13 03:15 AM (13 years ago)
Oh, nice! - yeah you're way is much easier...guess I was overcomplicating things (I have a feeling I do that a lot)
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.