我在CTSlidingup面板中有问题,它有问题。
显示错误
bottomController CTSlidingUpPanel.CTBottomSlideController吗?没有。 它显示上面的错误我该如何解决呢? CTsliding面板bottomController显示nil
import UIKit
import CTSlidingUpPanel
class ViewController: UIViewController, CTBottomSlideDelegate {
@IBOutlet weak var bottomView: UIView!
var bottomController:CTBottomSlideController?;
override func viewDidLoad() {
super.viewDidLoad()
bottomController = CTBottomSlideController(parent: view, bottomView: bottomView, tabController: self.tabBarController!, navController: self.navigationController, visibleHeight: 64)
bottomController?.setAnchorPoint(anchor: 0.7)
bottomController?.delegate = self;
bottomController?.onPanelExpanded = {
print("Panel Expanded in closure")
}
bottomController?.onPanelCollapsed = {
print("Panel Collapsed in closure")
}
bottomController?.onPanelMoved = { offset in
print("Panel moved in closure " + offset.description)
}
//Uncomment to specify top margin on expanded panel
//bottomController?.setExpandedTopMargin(pixels: 100)
if bottomController?.currentState == .collapsed
{
//do anything, i don't care
}
}
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
bottomController?.viewWillTransition(to: size, with: coordinator)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func didPanelCollapse()
{
print("Collapsed");
}
func didPanelExpand(){
print("Expanded")
}
func didPanelAnchor(){
print("Anchored")
}
func didPanelMove(panelOffset: CGFloat)
{
print(panelOffset);
}
}
或建议滑动面板库。或举一些例子
答案 0 :(得分:0)
答案 1 :(得分:0)
看,根据您的屏幕截图判断,您没有 tabBarController 。
bottomController = CTBottomSlideController(parent: view, bottomView: bottomView, tabController: self.tabBarController!, navController: self.navigationController, visibleHeight: 64)
在初始化程序中,如果您使用 self.tabBarController!(请注意感叹号),并且没有 tabBarController ,此行将引发错误
自述文件中所述,您可以做的是为该参数提供无。