2016-11-19 64 views
0

我有使用SWRevealViewController的前視圖和後視圖。 我是新來的(SWRevealViewController)。
當我在前視圖中點擊導航菜單按鈕時,我想要完整的後視圖,但它不會到來。
我試過了,但我的後視最右邊的按鈕沒有顯示。 有沒有什麼問題,或者我需要添加一些額外的東西。
這裏是我的代碼: -
前視圖: -SWRevealViewController後視圖寬度未完全顯示

class HomeViewController: UIViewController,SWRevealViewControllerDelegate { 

@IBOutlet weak var openSlideMenuView: UIBarButtonItem! 

override func viewDidLoad() { 
    super.viewDidLoad() 


    if self.revealViewController() != nil { 

     openSlideMenuView.target = self.revealViewController() 
     openSlideMenuView.action = #selector(SWRevealViewController.revealToggle(_:)) 

     self.navigationController?.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer()) 
    } 

} 

感謝

回答

0

在我的環境我用UserDefault設置這兩個功能,這些功能在我mainViewController。

如果這是你正在尋找的答案不要忘記除了答案。

func changeShadow(){ 
    let defaults: UserDefaults = UserDefaults.standard 
    let shadowColor    = defaults.object(forKey: "shadowColorID") as? Int 
    if shadowColor == 1 { 
     revealViewController().frontViewShadowColor = UIColor.red 
    }else if shadowColor == 2{ 
     revealViewController().frontViewShadowColor = UIColor.blue 
    }else if shadowColor == 3{ 
     revealViewController().frontViewShadowColor = UIColor.green 
    } 
} 


func changeReveal(){ 
    let defaults: UserDefaults = UserDefaults.standard 
    let revealWidth    = defaults.object(forKey: "widthID") as? Int 
    if revealWidth == 1 { 
     revealViewController().rightViewRevealWidth = (view.frame.width/5*4) 
    }else if revealWidth == 2{ 
     revealViewController().rightViewRevealWidth = (view.frame.width/6*5) 
    }else if revealWidth == 3{ 
     revealViewController().rightViewRevealWidth = (view.frame.width/7*6) 
    }else if revealWidth == 4{ 
     revealViewController().rightViewRevealWidth = (view.frame.width/8*7) 
    }else if revealWidth == 5{ 
     revealViewController().rightViewRevealWidth = (view.frame.width) 
    } 
} 

看着你SWRevealViewController.h這條線241

// Defines how much of the rear or right view is shown, default is 260. 
// Negative values indicate that the reveal width should be computed by substracting the full front view width, 
// so the revealed frontView width is kept constant when bounds change as opposed to the rear or right width. 
@property (nonatomic) CGFloat rearViewRevealWidth; 
@property (nonatomic) CGFloat rightViewRevealWidth; // <-- simetric implementation of the above for the rightViewController 

// Defines how much of an overdraw can occur when dragging further than 'rearViewRevealWidth', default is 60. 
@property (nonatomic) CGFloat rearViewRevealOverdraw; 
@property (nonatomic) CGFloat rightViewRevealOverdraw; // <-- simetric implementation of the above for the rightViewController 

// Defines how much displacement is applied to the rear view when animating or dragging the front view, default is 40. 
@property (nonatomic) CGFloat rearViewRevealDisplacement; 
@property (nonatomic) CGFloat rightViewRevealDisplacement; // <-- simetric implementation of the above for the rightViewController 
+0

沒有我要求,在我的後面按鈕最右邊的按鈕沒有顯示。 如果rearViewRevealWidth = self.view.frame.width – kishor0011

+0

我不確定您的後方VC如何設置或佈局。也許重置約束。 – dscrown

+0

好的,謝謝,我會嘗試 – kishor0011