0

Hi I am developing an IOS application. I don't use autolayout. If my app run at iPhone 5(4") simulator then showing black top and bottom place. Simulated metricks size also none. What can I do.

enter image description here

Thanx

hiwordls
  • 781
  • 7
  • 17
  • 35
  • @Euroboy no this is not true, You can use the AutoResizeMask to make your grow with the screen size. The black are there because you did not supply a `Default-568@2x.png` launch screen. – rckoenes Jan 14 '14 at 10:00
  • @rckoenes I added Default-568@2x.png but did not. I writed this code in appdelegate self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; self.window.frame = CGRectMake(0, 0, [[UIScreen mainScreen]bounds].size.width, [[UIScreen mainScreen]bounds].size.height);. Because window always nil. – hiwordls Jan 14 '14 at 10:12
  • possible duplicate of [Black bars showing when running app on iOS 7 (4 inch retina display)](http://stackoverflow.com/questions/18913105/black-bars-showing-when-running-app-on-ios-7-4-inch-retina-display) – Matthias Bauch Jan 14 '14 at 12:07

2 Answers2

1

Just add an splash screen image named Default-568h@2x.png to your project folder black space will be removed automatically.

Ashutosh
  • 2,215
  • 14
  • 27
  • @ashu iPhone Retina (4-inc) IOS 6.0 simulator works fine but IOS 7 simulator doesn't work. I cleared project, delete drived data and also Reset Content and Settings but not work :( – hiwordls Jan 17 '14 at 08:49
0

Use UIView autoresizingMask property.

You can also check screen size and load specific image for iPhone 5.

I use some like this -

@implementation UIImage (iPhone5)

BOOL iPhone5Screen();

+(UIImage*)imageNamed5:(NSString *)name
{
    UIImage *retImage = nil;
    if (iPhone5Screen()) {
        NSString *imageName = [name stringByDeletingPathExtension];
        if ([imageName hasPrefix:@"@2x"]){
            imageName = [imageName substringToIndex:imageName.length - 3];
        }

        NSString *iPhone5ImageName = [NSString stringWithFormat:@"%@-568h", imageName];

        retImage = [UIImage imageNamed:iPhone5ImageName];
        if (retImage) {
            return retImage;
        }
    }

    return [UIImage imageNamed:name];
}

BOOL iPhone5Screen()
{
    BOOL bRet = NO;
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        bRet = NO;
    }
    else if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
        CGSize result = [[UIScreen mainScreen] bounds].size;
        if(result.height == 568){
            bRet = YES;
        }
    }

    return bRet;
}

@end
hiwordls
  • 781
  • 7
  • 17
  • 35
nswamy
  • 1,041
  • 9
  • 16