首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >调试时面临警告问题

调试时面临警告问题
EN

Stack Overflow用户
提问于 2015-11-16 12:49:52
回答 1查看 1.1K关注 0票数 4

背景

我正在拍摄viewController的截图,并在collectionViewCell中展示。collectionViewCell的布局是水平的,但是当我选择一个视图,然后旋转设备,然后返回到collectionView,布局是垂直的。

要调试:我在代码中放置了一个断点,在调试区域,我试图检查变量的输出,这是下面的警告开始出现的地方。

代码语言:javascript
复制
**Warning:**

error: property 'modalPresentationStyle' declared with incompatible types in different translation units ('UIModalPresentationStyle' vs. 'UIModalPresentationStyle')
error: instance method 'modalPresentationStyle' has incompatible result types in different translation units ('UIModalPresentationStyle' vs. 'UIModalPresentationStyle')
error: property 'modalPresentationStyle' declared with incompatible types in different translation units ('UIModalPresentationStyle' vs. 'UIModalPresentationStyle')
error: instance method 'modalPresentationStyle' has incompatible result types in different translation units ('UIModalPresentationStyle' vs. 'UIModalPresentationStyle')
error: property 'modalPresentationStyle' declared with incompatible types in different translation units ('UIModalPresentationStyle' vs. 'UIModalPresentationStyle')
error: instance method 'modalPresentationStyle' has incompatible result types in different translation units ('UIModalPresentationStyle' vs. 'UIModalPresentationStyle')
note: declared here with type 'UIModalPresentationStyle'
note: instance method 'modalPresentationStyle' also declared here
note: declared here with type 'UIModalPresentationStyle'
note: declared here with type 'UIModalPresentationStyle'
note: instance method 'modalPresentationStyle' also declared here
note: declared here with type 'UIModalPresentationStyle'
note: declared here with type 'UIModalPresentationStyle'
note: instance method 'modalPresentationStyle' also declared here
note: declared here with type 'UIModalPresentationStyle'
error: 6 errors parsing expression

我用的 :-

  • Xcode版本: 7.1
  • iOS: 9.1

注释--我在Xcode 6.4上使用iOS8运行的相同的代码,并且运行时没有出现故障/警告。此外,我还能够在调试区域中找到变量的值。

详细资料:-

断点- -我把它放在下面的方法中

代码语言:javascript
复制
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {

    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];

    UIViewController *viewController = (UIViewController *)_tabControllers[(NSUInteger)indexPath.row];

    /* Trying to debug above viewController in debug area */
    /* Some code is here also but of no use */

    cell.contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

    return cell;

}

在调试区域启动的命令-

po viewController

预期结果-

viewController的值,其细节类似于通常的框架。

实际结果-

上述警告。

我想要调试的东西-

collectionView单元格的布局在iOS 9中是自动变化的(在旋转后一个在下),而iOS 8中的其他布局(水平视图)是完美的。

提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-20 05:42:03

备选解决方案

基于您更新的关于想要处理UICollectionView旋转的评论。是否尝试将以下方法添加到包含集合视图的UIViewController中?

代码语言:javascript
复制
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
    [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];

    [coordinator animateAlongsideTransition:nil completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
        [self.collectionView performBatchUpdates:^{
            [self.collectionView setCollectionViewLayout:self.collectionView.collectionViewLayout animated:YES];
        } completion:nil];
    }];
}

在旋转视图方法中,可以在invalidateLayout上调用UICollectionView。

您可以尝试将UIImageView放入集合视图单元格并使用自动布局。然后将视图控制器的快照设置为UIImageView上的图像。

来自苹果的CollectionView项目示例

80+关于SO的其他问题 (可能提供一些见解)

警告

关于你所看到的警告。您所说的不重要的代码很可能是为UIModalPresentationStyle类型的属性分配无效值造成的(如果没有更重要的代码,就很难达到更高的精度)。此外,您所展示的代码在使用管道( autoresizingMask )时也有一个小问题。这些代码可以编码为[UIViewAutoresizingFlexibleWidth, UIViewAutoresizingFlexibleHeight]

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33735830

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档