所以我正在研究Swift中的iOS项目,我想创建一个包含一些有用内容的静态库.
我的问题是当我尝试在Xcode(版本6.3)中构建我的lib时,我有一个"Build Failed",然后是: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: unknown option character 'X' in: -Xlinker
我从来没有见过这个,这不是我的第一个静态库.所以我在想我可能与我只使用Swift类这一事实有关.
你们有什么感想 ?先感谢您.
我希望我的应用程序针对每个辅助功能选项进行优化,包括文本大小。
我根据具有组合布局的部分制作了一个 collectionView 布局。所以我需要我的单元格的高度随着它的内容增长。我认为 using.estimated(constant)可以完成这项工作,但它似乎不起作用。内部约束对我来说似乎很好。
这是我正在使用的布局:
let size = NSCollectionLayoutSize(widthDimension: .fractionalWidth(0.42), heightDimension: .estimated(90))
let item = NSCollectionLayoutItem(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .estimated(90)))
item.contentInsets = NSDirectionalEdgeInsets(top: 5.0, leading: 12.0, bottom: 5.0, trailing: 12.0)
let group = NSCollectionLayoutGroup.vertical(layoutSize: size, subitem: item, count: 1)
let section = NSCollectionLayoutSection(group: group)
section.contentInsets = NSDirectionalEdgeInsets(top: 0.0, leading: 6.0, bottom: 0.0, trailing: 0.0)
section.orthogonalScrollingBehavior = .groupPaging
Run Code Online (Sandbox Code Playgroud)
当我在辅助功能设置上设置更高的文本大小时,会发生什么:
单元格应该包含 2 个标签,这里是 autoLayoutConstraints :
NSLayoutConstraint.activate([
self.titleLabel.topAnchor.constraint(equalTo: self.container.topAnchor, constant: 10),
self.titleLabel.leftAnchor.constraint(equalTo: self.container.leftAnchor, constant: 20),
self.titleLabel.rightAnchor.constraint(equalTo: self.container.rightAnchor, constant: -20)
]) …Run Code Online (Sandbox Code Playgroud) 所以我正在开发一个包含Swift和Objective-C类的iOS项目.
为了实例化Objective-C中描述的对象,我理解我需要一个Bridging-Header文件,其中包含我将在Swift类中使用的所有头文件的导入.它在我的项目中运行良好.我创建了我需要的所有类,我在Swift中继承了Objective-C类,一切都很好.
我的问题是在相反的情况下:在Objective-C文件中实例化一个swift对象.所以我读到我需要有这些选项:
#import "<#YourProjectName#>-Swift.h"在我正在处理的*.m文件中添加这一行.这就是我所做的:
我更改了需要更改的构建设置上的所有值.我添加了该import行,我甚至尝试创建头文件,但我仍然有"<#YourProjectName#>-Swift.h" file not found错误.
当然,我通过实际的模块名称,一个我发现下更换为yourprojectname 产品模块名称在包装上构建设置部分.此外,项目名称中没有空格.
我忘记了一步吗?
谢谢您的帮助.
如何对实现协议的类进行扩展?
类似的东西:
protocol proto {
func hey()
}
Run Code Online (Sandbox Code Playgroud)
以及符合以下条件的类proto:
Class MyClass: UIViewController, proto {
func hey() {
print("Hey!")
}
}
Run Code Online (Sandbox Code Playgroud)
然后是该类的扩展,如下所示:
extension UIViewController where Self:proto {
func test() {
print("I'm extended!")
}
}
Run Code Online (Sandbox Code Playgroud)
这样我就可以打电话self.test()了MyClass。
谢谢。
所以我试图在我的Swift iOS应用程序中的SLRequest对象上使用performRequestWithHandler块,我无法处理NSError对象.这就是我的代码的样子:
posts.performRequestWithHandler({(response:NSData!, urlResponse:NSHTTPURLResponse!, error:NSError!) in
self.data = NSJSONSerialization.JSONObjectWithData(response, options: NSJSONReadingOptions.MutableLeaves, error: &error)
})
Run Code Online (Sandbox Code Playgroud)
我&error说错了:'NSError' is not convertible to '@lvalue inout $T9' in Swift.有谁知道这意味着什么?
先感谢您.
(我正在使用Xcode Beta 6 v7和OS X 10.10)