我无法得到以下代码来编译,任何建议的人?错误 - UIImageView UIScrollView播放背景视频
import UIKit
class ViewController: UIViewController, UIScrollViewDelegate {
@IBOutlet weak var avatar: UIImageView!
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var contentImageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
avatar.layer.cornerRadius = 5.0
avatar.layer.borderWidth = 4.0
avatar.layer.borderColor = UIColor.whiteColor().CGColor
avatar.clipsToBounds = true
scrollView.delegate = self
contentImageView.clipsToBounds = true
}
override func viewDidAppear(animated: Bool) {
let vc = self.storyboard?.instantiateViewControllerWithIdentifier("LoginScreen") as! UIViewController
self.presentViewController(vc, animated: true, completion: nil)
}
func scrollViewDidScroll(scrollView: UIScrollView) {
let yOffset = self.scrollView.contentOffset.y * 0.2
let availableOffset = min(yOffset, 60)
let contentRectYOffset = availableOffset/contentImageView.frame.size.height
contentImageView.layer.contentsRect = CGRectMake(0.0, contentRectYOffset, 1, 1);
}
}
的错误是
“从低迷现状“的UIViewController?到'UIViewController'只展开 optionals;你的意思是使用'!'
这发生在该行
let vc = self.storyboard?.instantiateViewControllerWithIdentifier("LoginScreen") as! UIViewController
有什么错误?它发生在哪里? – rmaddy
错误是'从'UIViewController'下降'?到'UIViewController'只解开optionals;你的意思是使用'!' ----------这发生在行----让vc = self.storyboard?.instantiateViewControllerWithIdentifier(“LoginScreen”)as! UIViewController – Indy
用所有相关细节更新您的问题,以便人们可以帮助您。 – rmaddy