当我启动iPhone Retina 64位模拟器时,奇怪的应用程序行为

时间:2014-07-25 17:21:14

标签: ios objective-c xcode

我有2个问题,我发现在64位模拟器上启动我的应用程序。首先,看一下这两个截图:

第一个截图是在iPhone模拟器4上制作的(iPhone模拟器3.5工作正常)。第二个是在iPhone 4 Retina 64位模拟器上启动应用程序。使用UIView和UICollectionView表示矩形。为什么这不适用于64位模拟器? Xcode中有错误或我在代码中犯了错误吗?此外,我的方法包括UIGestureRecognizer工作不好。那是:

-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {

    NSLog(@"Swipe received.");
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];

    self.myCollectionView.frame=CGRectMake(0, 0, 320, 480);

    [UIView commitAnimations];

    if (IS_IPHONE_5){
        NSLog(@" its iphone 5");
    }
}

-(void)handleSwipeDown:(UISwipeGestureRecognizer *)recognizer {

    NSLog(@"Swipe received.");
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];

    self.myCollectionView.frame=CGRectMake(0, 152, 320, 480);

    [UIView commitAnimations];

    if (IS_IPHONE_5){
        NSLog(@" its iphone 5");
    }
}

-(void)swipeUp{

    UISwipeGestureRecognizer *recognizer;

    recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionUp)];
    [[self view] addGestureRecognizer:recognizer];
}

-(void)swipeDown{

    UISwipeGestureRecognizer *recognizer;

    recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeDown:)];
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionDown)];
    [[self view] addGestureRecognizer:recognizer];
}

当它在iPhone 3,5或iPhone 4上推出时,滑动效果非常好,但在64位上几乎不能轻扫,然后我无法向下滑动。它实际上会自动滑动细胞,而不是移动框架。

Xcode有错误吗?我的应用程序在发布时会在iPhone 5S中正常运行吗?

任何建议都将不胜感激,谢谢!

2 个答案:

答案 0 :(得分:1)

这一行肯定是错误的

self.myCollectionView.frame = CGRectMake(0,152,320,480);

在你设置框架的地方,.. 480,所以collectionView必须变形,而是使用

self.myCollectionView.frame = CGRectMake(0,152,self.view.frame.size.width,self.view.frame.size.height);

然后尝试运行

答案 1 :(得分:0)

对于所有对我找到的解决方案感兴趣的人,请阅读以下内容:

对于颜色,我在故事板中检查了CollectionView颜色,设置为浅蓝色(您可以在第二个屏幕中看到它)。然后,我在故事板中禁用ScrollingEnabled和Bounces Zoom,之后,我的滑动手势识别器再次开始按预期工作。然后,我以编程方式设置颜色;

//That is method from category i add. It just simplify setting RGB colour for UIColor class
self.myCollectionView.backgroundColor = [UIColor colorWithR:100 G:100 B:100 A:1];

有结果: enter image description here

您可能会注意到,单元格中没有黑色边框。好吧,我可以忍受它,只要我有每个细胞的自定义图像。

我仍然不明白,为什么64位设备(包括iPad 64位模拟器)的应用程序行为也有所不同。我希望Apple能在下一版Xcode中修复它。