使用Beta 3一切正常,现在我得到一个奇怪的错误,我不知道如何解决它.尝试了解类似问题的所有解决方案.
这是我的代码:
if !name.isEmpty {
var splitted: [String] = name.componentsSeparatedByString(" ")
for curPart in splitted {
if !curPart.isEmpty {
acronym += curPart.substringToIndex(1) //Error
}
}
if (acronym as NSString).length > 2 {
acronym = acronym.substringToIndex(2) //Error
}
}
Run Code Online (Sandbox Code Playgroud)
两条标记的线都给了我同样的错误:
类型'String.Index'不符合协议'IntegerLiteralConvertible'
有人能帮我吗?或者Beta 4被窃听?谢谢!
嘿Stackoverflow成员,也许你可以帮我解决我的问题.
问题是我想将所有UIViewControllers的方向锁定为"Portrait",但如果MoviePlayer出现,它应该切换到横向模式,如果电影播放器消失则返回.
直到Swift 1.2我用过:
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow) -> UIInterfaceOrientationMask {
//If the video is being presented, let the user change orientation, otherwise don't.
if let presentedViewController = window.rootViewController?.presentedViewController? {
if (presentedViewController.isKindOfClass(MPMoviePlayerViewController) && !presentedViewController.isBeingDismissed()) {
return .AllButUpsideDown
}
}
return .Portrait
}
Run Code Online (Sandbox Code Playgroud)
使用Swift 1.2,有些东西发生了变化,所以我最终得到了以下代码:
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> Int {
//If the video is being presented, let the user change orientation, otherwise don't.
if let presentedViewController = window?.rootViewController?.presentedViewController {
if (presentedViewController.isKindOfClass(MPMoviePlayerViewController) && !presentedViewController.isBeingDismissed()) {
return …Run Code Online (Sandbox Code Playgroud)