NavigationTitle闪烁

时间:2017-04-27 12:21:43

标签: ios swift

如果应用程序被杀死并且用户点击推送通知应用程序将其直接带到相应的屏幕(详情屏幕),但在推送到详细信息屏幕之前我们将推送到列表屏幕。当用户单击详细信息屏幕导航标题的后退按钮时列表屏幕空了一秒然后才能正确。这可能是原因。

switch(model!.action[1].lowercased()){
          case "profile":
                    NotificationUtils.sharedInstance.moveToDirectoryModuleWithLTDS()    //Will shift to Directory module
                    NotificationUtils.sharedInstance.moveToLocationList(false)

                    NotificationUtils.sharedInstance.moveToLocation(Guid(locID),rightPanel: false, needAnimation: false) //Move to department detail screen with Info tab selected
                    hideLoader() //Will stop loading indicator
                    break
}

func moveToLocationList(_ animate: Bool = true) {
         hideNavigationTitle()   //This function is used to clear the back button title.
        let dropVC = DepartmentViewController(nibName: "DepartmentViewController", bundle: nil)
        dropVC.employeeGroupInfo = EmployeeGroupInfo.locationInfo
        self.pushWithDelayToVC(dropVC, animation: animate)
    }

 func pushWithDelayToVC(_ viewController:UIViewController,animation:Bool = true)
   {
    let appDelegate = UIApplication.shared.delegate as! AppDelegate
    AppDelegate.removeUserProfileSetupScreens()

    self.removeComposer { () -> Void in
        UIUtils.pushViewWhenHideBottom((appDelegate.tabBarController.selectedViewController as! UINavigationController).visibleViewController!, anotherVC: viewController, needAnimation: animation)
        self.hideSidePanel()
    }
}

func removeComposer(_ completion: @escaping (() -> Void))
{
    let appDelegate = UIApplication.shared.delegate as! AppDelegate

    if let selectedController = appDelegate.tabBarController.selectedViewController
    {
        if let selectNavController = selectedController as? UINavigationController
        {
            if let visibleController = selectNavController.visibleViewController
            {
                if (NSStringFromClass(type(of: visibleController)) == "MFMailComposeInternalViewController" || NSStringFromClass(type(of: visibleController)) == "CKSMSComposeController" || NSStringFromClass(type(of: visibleController)) == "PLUICameraViewController" || NSStringFromClass(type(of: visibleController)) == "UIAlertController")
                {
                    visibleController.dismiss(animated: false, completion: { () -> Void in
                        completion()
                        return
                    })
                }
                else
                {
                    completion()
                }
            }
            else { completion() }
        }
        else { completion()}
    }
    else { completion() }
}

viewWillAppear的代码是:

 override func viewWillAppear(_ animated: Bool) {
     super.viewWillAppear(animated)

    if employeeGroupInfo == EmployeeGroupInfo.departmentInfo {
        UIUtils.setTitleFontWhiteOnNavigationController(viewCtrl: self, titleStr: AppMessage.EDByDepartment)
    } else if employeeGroupInfo == EmployeeGroupInfo.locationInfo {
        UIUtils.setTitleFontWhiteOnNavigationController(viewCtrl: self, titleStr: AppMessage.EDByLocation)
    } else if employeeGroupInfo == EmployeeGroupInfo.teamInfo {
        UIUtils.setTitleFontWhiteOnNavigationController(viewCtrl: self, titleStr: AppMessage.EDMoreByTeamsMob)
    }

    self.tabBarController?.tabBar.isHidden = false

}

public class func setTitleFontWhiteOnNavigationController(viewCtrl: UIViewController, titleStr: String, needBorder: Bool = true,needTitleImage: Bool = false)
{
    viewCtrl.extendedLayoutIncludesOpaqueBars = true
    viewCtrl.navigationController?.navigationBar.isTranslucent = false
    viewCtrl.navigationController?.navigationBar.barTintColor = UIColor.LTColor()
    // Set navigation bar background color
    viewCtrl.navigationController?.navigationBar.tintColor = UIColor.white

    viewCtrl.navigationController?.navigationBar.titleTextAttributes = [NSFontAttributeName: UIFont.boldSystemFont(ofSize: 18.0),NSForegroundColorAttributeName: UIColor.white]

    if needTitleImage {
        setImageWithTitle(viewCtrl: viewCtrl,titleStr: titleStr)
    }
    else {
        viewCtrl.title = titleStr
    }
    if needBorder
    {
        //Used to hide shadow line in navigation bar by Nikhil
        viewCtrl.navigationController?.navigationBar.setBackgroundImage(nil, for: UIBarMetrics.default)
        viewCtrl.navigationController?.navigationBar.shadowImage = nil
    }
    else
    {
        //Used to hide shadow line in navigation bar by Nikhil
        viewCtrl.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
        viewCtrl.navigationController?.navigationBar.shadowImage = UIImage()
    }

}

0 个答案:

没有答案