我有使用数据重新加载的问题UICollectionView.我有这个数组viewDidLoad来填补UICollectionView.
array = [[NSMutableArray alloc] init];
[array addObject:@"1"];
[array addObject:@"2"];
[array addObject:@"3"];
[array addObject:@"4"];
[array addObject:@"5"];
[array addObject:@"6"];
Run Code Online (Sandbox Code Playgroud)
和方法:
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = @"Cell";
//cell = [[UICollectionViewCell alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
myCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, 100, 20)];
[titleLabel setText:[array objectAtIndex:indexPath.row]];
titleLabel.textColor = [UIColor whiteColor];
titleLabel.backgroundColor = [UIColor clearColor];
[cell addSubview:titleLabel];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
我点击UIButton并重新加载数据:
[myCollectionView reloadData];
Run Code Online (Sandbox Code Playgroud)
这里重新加载之前和之后的数据如何:


我在3.5英寸屏幕上开发了一个应用程序,现在我为4英寸屏幕做了一个新的故事板,我喜欢跟随在appdelegate上的故事板之间切换,我记录了屏幕高度,它给了我480.00000检查它:
NSLog(@"Checking Screen Size");
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
{
NSLog(@"On iPhone");
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
if (iOSDeviceScreenSize.height == 480)
{ (diagonally measured)
NSLog(@"iPhone 4: %f", iOSDeviceScreenSize.height);
}
if (iOSDeviceScreenSize.height == 568)
{
NSLog(@"iPhone 5: %f", iOSDeviceScreenSize.height);
}
Run Code Online (Sandbox Code Playgroud)
我的手机是iPhone 5,NSLog给了我480.0000