ermalkaleci / CarbonKit

CarbonKit - iOS Components (Obj-C & Swift)
MIT License
682 stars 164 forks source link

Regarding CarbonTabSwipeNavigation position in iPad and Conflict SWRevealViewController #236

Open saritbahuguna1 opened 5 years ago

saritbahuguna1 commented 5 years ago

Dear @ermalkaleci ,

Hope you are doing well.

I am getting an issue only in iPad,I have CarbonTabSwipeNavigation with two tabs. in iPhone it is working fine . but in case of iPad I have issue regarding CarbonTabSwipeNavigation position i.e in status bar and CarbonTabSwipeNavigation have some black screen.

It is also conflict with SWRevealViewController functionality . I have SWRevealViewController when I swap left most tab of CarbonTabSwipeNavigation , Simulator Screen Shot - iPad Air 2 - 2019-07-19 at 19 10 25

Simulator Screen Shot - iPad Air - 2019-07-19 at 20 00 34

my left SWRevealViewController is not open both iPhone and iPAd.

I have upload both screen in which I have show black screen and Left slider in which when I swap from flight tab screen to left side my left slider is not open . I don't know how it will fix. Can you help me for the same , if have any idea.

saritbahuguna1 commented 5 years ago

Dear @ermalkaleci ,

Please check my code.

//MARK: Carbon Tab Swipe NavigationDelegate func carbonTabSwipeNavigation(_ carbonTabSwipeNavigation: CarbonTabSwipeNavigation, viewControllerAt index: UInt) -> UIViewController { guard let storyboard = storyboard else { return UIViewController() } if index == 0 { return storyboard.instantiateViewController(withIdentifier: "FlightDashBoardViewController") } return storyboard.instantiateViewController(withIdentifier: "HotelDashBoardViewController") }

//MARK: View Life Cycle
override func viewDidLoad() {
    super.viewDidLoad()

}
override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(true)
    self.navigationController?.isNavigationBarHidden = false
    navigationItem.hidesBackButton = true
    if let StatusbarView = UIApplication.shared.value(forKey: "statusBar") as? UIView {
        StatusbarView.backgroundColor = UIColor(red: 26/255, green: 138/255, blue: 234/255, alpha: 1.0000)
    }

    let tabSwipe = CarbonTabSwipeNavigation(items: [iconWithTextImageFlight, iconWithTextImageHotel], delegate: self)

    let widthOfTabIcons = self.view.frame.size.width/2
    tabSwipe.carbonSegmentedControl!.setWidth(widthOfTabIcons, forSegmentAt: 0)
    tabSwipe.carbonSegmentedControl!.setWidth(widthOfTabIcons, forSegmentAt: 1)
    self.view.backgroundColor = UIColor.white
    tabSwipe .setNormalColor(UIColor.white)
    tabSwipe.setSelectedColor(UIColor.white)
    tabSwipe.setIndicatorColor(customOrangeColor)
    tabSwipe.carbonTabSwipeScrollView.backgroundColor =         UIColor(red: 0.0513, green: 0.3407, blue: 0.6431, alpha: 1.0000)
    tabSwipe.insert(intoRootViewController: self)

    sideMenus()

}

//MARK: Custom Methods

@objc func recentSearch(){
    print("clicked")
    self.navigationController?.dismiss(animated: true, completion: nil)
}
func sideMenus() {
    if self.revealViewController() != nil {
        menuButton.target = revealViewController()
        menuButton.action = #selector(SWRevealViewController.revealToggle(_:))
        revealViewController().rearViewRevealWidth = 275
        revealViewController().rightViewRevealWidth = 275
        alertButton.target = revealViewController()
        alertButton.action = #selector(SWRevealViewController.rightRevealToggle(_:))
    view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())

    }

}
var iconWithTextImageFlight: UIImage {
    let button = UIButton()
    let icon = UIImage(named: "Flight")
    button.setImage(icon, for: .normal)
    button.setTitle("Flight", for: .normal)
    button.titleLabel?.font = Custome_Font_Regular_17
    button.contentEdgeInsets = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 10)
    button.imageEdgeInsets = UIEdgeInsets(top: 0, left: -10, bottom: 0, right: 10)
    button.sizeToFit()
    return generateImage(for: button) ?? UIImage()
}
var iconWithTextImageHotel: UIImage {
    let button = UIButton()
    let icon = UIImage(named: "HotelIphone")
    button.setImage(icon, for: .normal)
    button.setTitle("Hotel", for: .normal)
    button.setTitleColor(UIColor.white, for: .normal)
    button.titleLabel?.font = Custome_Font_Regular_17
    button.contentEdgeInsets = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 10)
    button.imageEdgeInsets = UIEdgeInsets(top: 0, left: -10, bottom: 0, right: 10)
    button.sizeToFit()
    return generateImage(for: button) ?? UIImage()
}

func generateImage(for view: UIView) -> UIImage? {
    defer {
        UIGraphicsEndImageContext()
    }
    UIGraphicsBeginImageContextWithOptions(view.bounds.size, false, UIScreen.main.scale)
    if let context = UIGraphicsGetCurrentContext() {
        view.layer.render(in: context)
        return UIGraphicsGetImageFromCurrentImageContext()
    }
    return nil
}
ermalkaleci commented 5 years ago

@saritbahuguna1 it’s not related to carbonkit

Sent with GitHawk

saritbahuguna1 commented 5 years ago

@ermalkaleci I have 2 carbonkit Nav Tab 1 Flight 2 is Hotel. In both Tab I have Recent Search in Top Of Navigation .When I am in First Tab i.e Flight Tab and click on Recent Search My flight recent search as a slider is open and when I Tap on Flight recent Search it will auto fill in First view which one is Flight.Thats working fine. But In case when I am in 2nd Tab Hotel and open Hotel Recent Search as a slider , when I select Hotel Recent Search It Will show first time me Flight view which one is Index is 0. how to auto Change 0 to 1 when I select recent search from Tab 2 Hoel.

Simulator Screen Shot - iPhone Xs Max - 2019-09-02 at 11 13 01 Simulator Screen Shot - iPhone Xs Max - 2019-09-02 at 11 13 04 Simulator Screen Shot - iPhone Xs Max - 2019-09-02 at 11 13 39 Simulator Screen Shot - iPhone Xs Max - 2019-09-02 at 11 13 08

saritbahuguna1 commented 5 years ago

@saritbahuguna1 it’s not related to carbonkit

Sent with GitHawk

Hello @ermalkaleci Okay

saritbahuguna1 commented 5 years ago

Done..