0

I've created a modal segue to a viewController, however when i trigger this segue, there seem to be some delay when viewing the viewController. All i have in the viewController is in the viewDidLoad. what could course this slow modal segue?

override func viewDidLoad() {
    super.viewDidLoad()

    self.title = "Caption".uppercaseString

    self.view.backgroundColor = UIColor(hexString: "#0B1E30")

    self.navigationController?.navigationBar.barTintColor = UIColor(gradientStyle: UIGradientStyle.LeftToRight, withFrame: CGRectMake(0, 0, self.view.frame.width, (self.navigationController?.navigationBar.frame.height)! + 20), andColors: [UIColor(hexString: "#7F5CE6"), UIColor(hexString: "#9D8FE2")])

    let closeButton = UIBarButtonItem(image: UIImage(named: "Cross"), style: UIBarButtonItemStyle.Done, target: self, action: "dismissController")
    self.navigationItem.leftBarButtonItem = closeButton

    textView?.text = "Add caption (optional)"
    textView?.becomeFirstResponder()
    textView?.keyboardAppearance = UIKeyboardAppearance.Dark
    textView?.font = UIFont(name: "Montserrat-Light", size: 13)
    textView?.textColor = UIColor(hexString: "#363636")

    capturedImageView = UIImageView(image: capturedPhoto)
    capturedImageView?.frame = CGRectMake(8,10, 85, 85)
    let path = UIBezierPath(rect: CGRectMake(8, 10, 85, 85))
    textView?.textContainer.exclusionPaths = [path]
    textView?.addSubview(capturedImageView!)

    facebookButton?.tag = 1
    facebookButton!.adjustsImageWhenHighlighted = false
    facebookButton?.addTarget(self, action: "tapSocial:", forControlEvents: UIControlEvents.TouchUpInside)
    facebookButton?.tintColor = UIColor.whiteColor()
    facebookButton?.backgroundColor = UIColor(hexString: "#395798")
    facebookButton?.contentMode = UIViewContentMode.Center
    facebookButton?.setTitle("", forState: UIControlState.Normal)

    let fBorder = CALayer()
    let width = CGFloat(1.0)
    fBorder.borderColor = UIColor.whiteColor().colorWithAlphaComponent(0.05).CGColor
    fBorder.frame = CGRect(x: 0, y: facebookButton!.frame.size.height - width, width:  facebookButton!.frame.size.width, height: facebookButton!.frame.size.height)

    fBorder.borderWidth = width
    facebookButton!.layer.addSublayer(fBorder)
    facebookButton!.layer.masksToBounds = true


    twitterButton?.tag = 2
    twitterButton!.adjustsImageWhenHighlighted = false
    twitterButton?.addTarget(self, action: "tapSocial:", forControlEvents: UIControlEvents.TouchUpInside)
    twitterButton?.contentMode = UIViewContentMode.Center
    twitterButton?.tintColor = UIColor.whiteColor()
    twitterButton?.setTitle("", forState: UIControlState.Normal)

    let tBorder = CALayer()
    tBorder.borderColor = UIColor.whiteColor().colorWithAlphaComponent(0.05).CGColor
    tBorder.frame = CGRect(x: 0, y: twitterButton!.frame.size.height - width, width:  twitterButton!.frame.size.width, height: twitterButton!.frame.size.height)
    tBorder.borderWidth = width
    twitterButton!.layer.addSublayer(tBorder)
    twitterButton!.layer.masksToBounds = true

    let tRightBorder = CALayer()
    tRightBorder.borderColor = UIColor.whiteColor().colorWithAlphaComponent(0.05).CGColor
    tRightBorder.frame = CGRect(x: 0, y: 0, width:  width, height: twitterButton!.frame.size.height)

    tRightBorder.borderWidth = width
    twitterButton!.layer.addSublayer(tRightBorder)

    instagramButton?.tag = 3
    instagramButton!.adjustsImageWhenHighlighted = false
    instagramButton?.addTarget(self, action: "tapSocial:", forControlEvents: UIControlEvents.TouchUpInside)
    instagramButton?.contentMode = UIViewContentMode.Center
    instagramButton?.tintColor = UIColor.whiteColor()
    instagramButton?.setTitle("", forState: UIControlState.Normal)

    let iBorder = CALayer()
         iBorder.borderColor = UIColor.whiteColor().colorWithAlphaComponent(0.05).CGColor
    iBorder.frame = CGRect(x: 0, y: instagramButton!.frame.size.height - width, width:  instagramButton!.frame.size.width, height: instagramButton!.frame.size.height)

    iBorder.borderWidth = width
    instagramButton!.layer.addSublayer(iBorder)
    instagramButton!.layer.masksToBounds = true

    let iLeftBorder = CALayer()
    iLeftBorder.borderColor = UIColor.whiteColor().colorWithAlphaComponent(0.05).CGColor
    iLeftBorder.frame = CGRect(x: 0, y: 0, width:  width, height: instagramButton!.frame.size.height)

    iLeftBorder.borderWidth = width
    instagramButton!.layer.addSublayer(iLeftBorder)

}
Peter Pik
  • 11,023
  • 19
  • 84
  • 142

1 Answers1

1

This came as a surprise for me but apparently there is a performance issue with textView's property "selectable" when set to true by default (checked on Storyboard).

Try going to your Storyboard, select each textView and uncheck the box "selectable". If you need the textView to be selectable, then just set selectable to true programatically on your viewDidLoad.