我一步一步地跟着MD文件.但是编译中仍然存在错误.我能做什么?
在FaceppClient.m文件中:
if ([[[UIDevice currentDevice] systemVersion] compare: @"5.0" options: NSNumericSearch ] != NSOrderedAscending)
_ios50orNewer = true;
Run Code Online (Sandbox Code Playgroud)
Xcode输出此错误:
使用未声明的标识符'UIDevice'
我#import "UIDevice.h"在文件中添加了,但Xcode输出"UIDevice.h not found".
我将UIKit框架添加到项目中,但我仍然有编译问题.
那我该怎么办?
我目前正在使用UICollectionView来显示3个图像(每个图像跨越整个单元格).我还有一个UIPageControl,我放在UICollectionView的顶部.我想要发生的是让UIPageControl显示图像的数量(在这种情况下是3),以及用户当前正在查看的图像.我想要的效果是Instagram应用程序的效果.
我目前用来实现这种效果的方法是将UIPageControl的更新放在UICollectionView的willDisplay函数中,如下所示:
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
pictureDots.currentPage = indexPath.item
}
Run Code Online (Sandbox Code Playgroud)
这样可以正确地连接集合视图和页面控件之间的分页效果.但是,我遇到的问题是UIPageControl开始说用户在第三个图像上,即使它正在显示第一个图像.
有谁知道为什么会这样,以及如何解决这个问题?
我目前正在尝试访问先前为其设置锚点的视图的高度。因此,例如,我searchTable在ViewController 中使用以下命令设置了左,右,顶部和底部锚点:
searchTable.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
searchTable.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
searchTable.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true
searchTable.bottomAnchor.constraint(equalTo: menuBar.topAnchor).isActive = true
Run Code Online (Sandbox Code Playgroud)
searchTable是我创建的类的对象,该类继承自UIView并具有UIImageView。我通过在init函数中使用以下内容来约束UIImageView:
imageView.topAnchor.constraint(equalTo: topContainer.topAnchor, constant: 10).isActive = true
imageView.leftAnchor.constraint(equalTo: topContainer.leftAnchor, constant: 10).isActive = true
imageView.heightAnchor.constraint(equalTo: self.heightAnchor, multiplier: topContainerMultiplier * imageProfileMultiplier).isActive = true
imageView.widthAnchor.constraint(equalTo: self.heightAnchor, multiplier: topContainerMultiplier * imageProfileMultiplier).isActive = true
Run Code Online (Sandbox Code Playgroud)
哪里:
let topContainerMultipler: Double = 1 / 7
let imageProfileMultipler: Double = 1 / 5
Run Code Online (Sandbox Code Playgroud)
在的init函数中searchTable,我试图将角半径设置为图像大小的一半。我试图用self.frame.height,self.frame.size.height,self.bounds.height并且还获得.constant了价值self.heightAnchor约束,但都返回0。
我认为有解决此问题的解决方案,但我一直找不到。