我有这个代码在多个视图中滑动,但我得到了:
“致命错误:在解开可选值时意外发现nil”
当我做self.scrollView!.aaDubview(SurfView.view)
有什么建议吗?
class LoadViewController: UIViewController {
// Outlet used in storyboard
@IBOutlet var scrollView: UIScrollView?;
override func viewDidLoad() {
super.viewDidLoad();
var SkateView :LoadSkateViewController = LoadSkateViewController(nibName: "LoadSkateViewController", bundle: nil);
var LongboardView :LoadLongboardViewController = LoadLongboardViewController(nibName: "LoadLongboardViewController", bundle: nil);
var SurfView :LoadSurfViewController = LoadSurfViewController(nibName: "LoadSurfViewController", bundle: nil);
self.addChildViewController(SurfView)
self.scrollView!.addSubview(SurfView.view)
SurfView.didMoveToParentViewController(self)
self.addChildViewController(LongboardView)
self.scrollView!.addSubview(LongboardView.view)
LongboardView.didMoveToParentViewController(self)
self.addChildViewController(SkateView)
self.scrollView!.addSubview(SkateView.view)
SkateView.didMoveToParentViewController(self)
var adminFrame :CGRect = SkateView.view.frame
adminFrame.origin.x = adminFrame.width
LongboardView.view.frame = adminFrame
var BFrame :CGRect = LongboardView.view.frame
BFrame.origin.x = 2*BFrame.width
SurfView.view.frame = BFrame
var scrollWidth: CGFloat = 3 * self.view.frame.width
var scrollHeight: CGFloat = self.view.frame.size.height
self.scrollView!.contentSize = CGSizeMake(scrollWidth, scrollHeight);
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
此代码由Brendan Lee示例代码生成