-2

I am developing an application using collection view. Here I am posting a screenshot and my code also. There is no error or warning in my application and I am using Xcode 6. I fixed the size of my viewController to iPhone 4-inch and run the application in iPhone 5. It is showing me perfect in iPhone 5 but when i select a simulator iPhone 6, the layout is look something oak ward. I post both screen shot. can anyone help me to solve this If some one run on iPhone 6 then I must show in perfect layout.

Screen shot of iPhone 5

enter image description here

Screen shot of iPhone 6

enter image description here

here is my code

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController{
    NSMutableArray *array;
}

- (void)viewDidLoad {
    [super viewDidLoad];

    array = [[NSMutableArray alloc]init];
    [array addObject:@"Apple"];
    [array addObject:@"Samsung"];
    [array addObject:@"Sony"];
    [array addObject:@"HTC"];
    [array addObject:@"Blackberry"];
    [array addObject:@"Oneplus"];


}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark collection view methods


-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return [array count];
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{

    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
    UILabel *label = (UILabel *)[cell viewWithTag:100];
    label.text = [array objectAtIndex:indexPath.row];
    [cell.layer setBorderWidth:2.0f];
    [cell.layer setBorderColor:[UIColor whiteColor].CGColor];
    //[cell.layer setCornerRadius:50.0f];

    return cell;

}
@end
Bhargav
  • 139
  • 3
  • 12

4 Answers4

0

Please find helpful screen shot

I have added constraint as per your requirement

enter image description here

Abhishek Sharma
  • 3,283
  • 1
  • 13
  • 22
0

Use auto layout or autoresizing to make compatible for every devices. for auto layout go through this link.

http://captechconsulting.com/blog/jack-cox/ios-7-tutorial-series-auto-layout-xcode-5

for autoresizing

Autoresizing masks programmatically vs Interface Builder / xib / nib

and if you add component pragmatically then check screen width for every device.

[ [ UIScreen mainScreen ] bounds ].size.width
Community
  • 1
  • 1
0

Just go to images.xcassets, right clicking in the navigator area, add launchImage. Then select your project (or target), go to general-->App Icons and Launch images and set Launch Images Source as Launch Image and most importantly, set Launch Screen file blank.

The app would now work well in iphone 6 simulator too.enter image description here

PS: I also had the same problem. Solved it my self. See enter link description here

Community
  • 1
  • 1
Vamshi Krishna
  • 979
  • 9
  • 19
0

Just go to images.xcassets, right clicking in the navigator area, select Appicon. Then check the ios 7 and later sizes. if iOS 8 and later sizes selected then remove that check box. By doing that you will able to get your application run in all resolution iphone 4s,5 and 6.

See the screen shot.

enter image description here

jogshardik
  • 1,446
  • 1
  • 12
  • 23