Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 调试时遇到警告问题 背景_Ios_Objective C_Ios9_Uimodalpresentationstyle - Fatal编程技术网

Ios 调试时遇到警告问题 背景

Ios 调试时遇到警告问题 背景,ios,objective-c,ios9,uimodalpresentationstyle,Ios,Objective C,Ios9,Uimodalpresentationstyle,我正在拍摄一个viewController的屏幕截图,并在collectionViewCell中展示它。collectionViewCell的布局是水平的,但当我选择一个视图,然后旋转设备,然后返回collectionView时,布局是垂直的 调试:我在代码中放了一个断点,在调试区域我试图检查变量的输出,这就是下面警告开始出现的地方 **Warning:** error: property 'modalPresentationStyle' declared with incompatible

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

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

**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
注意-与我在带iOS8的Xcode 6.4上运行的代码相同,它运行时没有出现故障/警告。而且,我能够在调试区域中找到变量的值

更多信息:-

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

- (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的值,具有与通常一样的细节帧

实际结果-

上述警告

我要调试的内容-

在iOS 9中,collectionView单元格的布局会自动更改(旋转后一个单元格低于另一个单元格),而iOS 8中的其他单元格布局(水平视图)则是完美的

提前感谢。

其他解决方案 基于您关于希望处理UICollectionView旋转的最新评论。是否尝试将以下方法添加到包含集合视图的UIViewController中

- (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];
    }];
}
-(void)视图将转换大小:(CGSize)带有转换协调器的大小:(id)协调器
{
[super ViewWillTransitionSize:size with TransitionCoordinator:coordinator];
[协调员AnimateLongsideTransition:无完成:^(id上下文){
[self.collectionView性能更新:^{
[self.collectionView设置collectionViewLayout:self.collectionView.collectionViewLayout动画:是];
}完成:无];
}];
}

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

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

(可能提供一些见解)

警告
关于您看到的警告。您所说的不重要的代码可能是由于为UIModalPresentationStyle类型的属性指定了无效值造成的(如果没有更重要的代码,就很难获得更高的精度)。另外,您显示的代码有一个小问题,即在autoresizingMask中使用管道(|)。可以将其编码为
[UIViewAutoresizingFlexibleWidth,UIViewAutoresizingFlexibleHeight]

请在它结束之前把这当作一个恰当的问题。如果需要,请查看帮助。确保您没有在代码中的任何位置定义名为
UIModalPresentationStyle
的类型。您从何处获得这些警告?在调试器或编辑器中?@Mr.T处于调试区域,同时我使用命令“po variable_name”查找任何特定变量的值。@Avi我已使用UIModalPresentationStyle检查代码,并找到self.viewController.modalPresentationStyle=UIModalPresentationFormSheet;嗨,在启动collectionViewCell之前,我在cellForItemAtIndexPath方法中添加了[collectionView.collectionViewLayout invalidateLayout]。然后我就可以得到collectionView的正确布局,但当我尝试获取单元格帧时,它会显示纵向帧(当我旋转到横向时),反之亦然。