I have a background image being placed by the following:
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"v3_bg.png"]];
However, my image, which is 960x640 does not scale correctly when i run the simulator, in both v3 and v4 of the iphone. Could some one please help explain to me why the iphone simulator 4 does'nt use the full size of the image, it seems to only just scale up what the v3 displays.
Thoughts?
In the Simulator, go to Hardware>Device and select iPhone(Retina) rather than iPhone.
Related
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.
I have 3 images:
test.png
test#2x.png
test-568#2x.png
In IBOutlet, a UIImageView is set to display test.png.
On iPhone 3.5in without retina, it's displaying test.png
On iPhone 3.5in with retina, it's displaying test#2x.png
But on iPhone 4in with retina, it's displaying test#2x.png!!!
What's going on?
Thanks!
The -568#2x suffix only applies to the Default.png launch images. There is no special suffix used by UIImage imageNamed: (or the other UIImage methods). If you need a special image on the 4" screen, you need to add code to get the desired image yourself.
The following works for the iPhone. For the iPad, you would need additional images.
For the three versions of the background image, use the following names:
background-480h.png (320x480)
background-480h#2x.png (640x960)
background-568h#2x.png (640x1136)
(You don't need a "-568h.png" image because there's no 320x568 iPhone screen.)
When you set the background image, simply append the screen height to the image name:
NSString* imageName = [NSString stringWithFormat: #"background-%ih", (int)[[UIScreen mainScreen] bounds].size.height];
[view setBackgroundColor: [UIColor colorWithPatternImage: [UIImage imageNamed: imageName]]];
iOS automtically appends the "#2x" if applicable.
You could omit the "h" after the height in the image names, but I think it's nice to emulate the iOS convention for the default image.
I know it's an old thread but I was having trouble with the new screen sizes for iPhone 6/6+.
What I did is to use this naming convention for different image files:
none if #1x small old phones
#2x for iPhone 4
-568h#2x for iPhone 5
-667h#2x for iPhone 6
#3x for iPhone 6 Plus
And then to automatically generate (full size) images just by including the code from this Gist in the project:
https://gist.github.com/kevindelord/fe2e691d06ab745fbb00
You have nothing else to do. When you instantiate an image in your code:
[UIImage imageNamed:#"background.png”];
The categorised class from the Gist will automatically create an image corresponding to the current device.
There is a Pod for it UIImage+Autoresize documented on CocoaDocs.
Will this code go well resizing for iPhone 5
view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
In order to get iPhone 5 simulator
In Xcode 4.5 :
Goto: iOS Simulator->Hardware-> Devices
and then select iPhone retina 4-inch
In order for the app to use entire screen of iPhone 5 you just have to include launch image for 4" screen in your app. Otherwise it won't occupy the whole screen regardless of autoresizing masks.
There are 2 things that need to happen.
As #mifki said, you need to include the default launch image for the
iPhone 5. This will enable the use of the full height in your app.
Setting the autosizing mask will only work if your code is set to
position its view using the bounds of the view. If your code is
using hardcoded coordinates simply by setting the autosizing mask
won't work.
I tried to create an activity indicator using the following code
CGRect frame = CGRectMake(160, 160.0,40.0,40.0);
progressIndicator = [[[UIActivityIndicatorView alloc] initWithFrame:frame]autorelease];
[progressIndicator startAnimating];
progressIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
progressIndicator.hidesWhenStopped=YES;
[progressIndicator sizeToFit];
[self.view addSubview:progressIndicator];
This code is working correctly in all devices except iphone 4(ie. indicator not showing in iphone 4). For that reason, i was forced to change the UIActivityIndicatorViewStyleWhiteLarge to UIActivityIndicatorViewStyleGray so that activity indicator is shown in all devices. Can anyone explain me why this happens?
The large white indicator has no drop shadow on ios 4 like it does on ios 3. I'm not sure why apple removed the shadow, but the indicator is there. You just can't see it on a white background anymore. Use the grey one, or put a background behind it.
I opened a ticket against this a week after iOS 4 came out and have yet to receive even an acknowledgment of the issue. It works in iOS < 4, broken in iOS >= 4. Doubt it'll be fixed any time soon.
hi
i have the same problem as yours
however, actually the indicator is shown.
It may seem to be a hardware problem.
I guess that the retina display can not display the white display properly with white background.
because when the indicator was displayed on the black background, i could check that it worked.
I hope it may help you
in an iPhone app, I have a UITabBar with three tabs. One has a system image, two more have custom images. These are PNGs, 30x30, palette-based, mostly transparent. These images show up fine in the simulator, but on the device, all I see is a grey gradiented square on a tab. The shapes on these images are grey to begin with, but they do show up as expected on the simulator.
Any ideas, please?
The image should be white on transparent. It's in the UI design guide. In my case, it was grey on transparent. Simulator forgives that, the device does not.
The device itself is pickier about image formats than the simulator is. I've had a number of instances where things showed up in the simulator and didn't on the phone. What has always worked for me is to encode all of my PNGs as 24-bit PNG-24 (in Photoshop) -- for icons and the like, the increased file size is trivial, and it solves my issues with images not showing up.
After about 3 hours I noticed the not so obvious... the name of the file is processed with case sensitive rules on the device, but not within the XCode simulator (As of XCode 4.6).
For example:
If the actual file name (resource) is "first.png" then the following needs to be the case in your code ---
//DO THIS self.tabBarItem.image = [UIImage imageNamed:#"first.png"];
//NOT THIS self.tabBarItem.image = [UIImage imageNamed:#"First.png"];
Look into this first before changing your code.