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
Screen shot of iPhone 6
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