This is a migrated thread and some comments may be shown as answers.

Alert Showing Behind Main View After Multiple Segues

2 Answers 33 Views
Alert
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sam
Top achievements
Rank 2
Sam asked on 20 Feb 2016, 08:00 PM

Hi,

Hopefully this is very simple, but I was having trouble with the TKAlert appearing behind the view so I created a simple application that recreated the problem. It is set up as follows:

There are three view controllers which are shown in the 'simpleStoryboard.png' attachment. Each one has a next and/or back button and an alert button that shows a TKAlert.  The alert shows as expected on the first two but on the third it shows behind the view controller (if i make the master view of the third one transparent I can see the alert). The problem is not with the third controller because if you enter the story board at the second, it will work for the second and third.

What am I missing here?

For reference here is generally what each of the controllers classes look like:

 

import UIKit
 
class SecondController: UIViewController, TKAlertDelegate {
     
     
    @IBAction func backButton(sender: AnyObject) {
        goHome()
    }
     
    @IBAction func nextButton(sender: AnyObject) {
        OpenNextController()
    }
     
    func OpenNextController(){
        performSegueWithIdentifier("segueTwo", sender: self)
    }
     
     
    func goHome() {
        dismissViewControllerAnimated(true, completion: nil)
    }
     
     
    @IBAction func alertButton(sender: AnyObject) {
        showAlert(sender)
    }
     
     
    //MARK: TKAlert
     
    func showAlert(sender: AnyObject) {
         
        print("Trying to show alert...")
         
        let alert = TKAlert()
         
        alert.delegate = self
        alert.style.cornerRadius = 3
        alert.title = "TK Alert!"
        alert.message = "Is this working?"
        alert.style.buttonSpacing = 10
        alert.style.buttonsInset = UIEdgeInsetsMake(5, 5, 5, 5)
        alert.style.contentSeparatorWidth = 0
        alert.style.messageColor = UIColor(red:0.349, green:0.349, blue:0.349, alpha:1.00)
        alert.style.titleSeparatorWidth = -0.5
        alert.style.contentSeparatorWidth = 0
        alert.alertView.layer.shadowOpacity = 0.6
        alert.alertView.layer.shadowRadius = 3
        alert.alertView.layer.shadowOffset = CGSizeMake(0, 0)
        alert.alertView.layer.masksToBounds = false
        alert.style.backgroundColor = UIColor.whiteColor()
        alert.buttonsView.backgroundColor = UIColor.whiteColor()
        alert.style.showAnimation = TKAlertAnimation.SlideFromTop
         
        var action = alert.addActionWithTitle("Yes") { (TKAlert, TKAlertAction) -> Bool in
            return true
        }
         
        action.backgroundColor = UIColor(red: 0.882, green: 0.882, blue: 0.882, alpha: 1.00)
        action.titleColor = UIColor(red: 0.302, green: 0.302, blue: 0.302, alpha: 1.00)
        action.cornerRadius = 3
         
        action = alert.addActionWithTitle("No") { (TKAlert, TKAlertAction) -> Bool in
            return true
        }
        action.backgroundColor = UIColor(red: 0.961, green: 0.369, blue: 0.306, alpha: 1.00)
        action.titleColor = UIColor.whiteColor()
        action.cornerRadius = 3
         
         
        alert.show(true)
         
    }
     
    //MARK: - TKAlertDelegate
     
    func alertDidShow(alert: TKAlert) {
         
        print("apparently the alert is here")
         
        let view = TKView(frame: CGRectMake(20, -30, 60, 60))
        view.shape = TKPredefinedShape(type: TKShapeType.Circle, andSize: CGSizeZero)
        view.fill = TKSolidFill(color: UIColor(red: 0.961, green: 0.369, blue: 0.306, alpha: 1.00))
        //  view.fill =
        view.stroke = TKStroke(color: UIColor.whiteColor(), width: 3.0)
        view.transform = CGAffineTransformMakeScale(0.1, 0.1)
         
         
        alert.alertView.addSubview(view)
         
         
        UIView.animateWithDuration(0.7,
            delay: 0.0,
            usingSpringWithDamping: 0.3,
            initialSpringVelocity: 0.3,
            options: UIViewAnimationOptions.CurveEaseInOut,
            animations: { () -> Void in
                view.transform = CGAffineTransformIdentity
            }) { (Bool) -> Void in }
         
    }
     
 
}

 

Thanks,

Sam

2 Answers, 1 is accepted

Sort by
0
Accepted
Yoanna
Telerik team
answered on 23 Feb 2016, 09:50 AM
Hello Sam, 

Thank you for contacting us. 

It seems like this is an issue in TKAlert and I have logged it in our feedback portal. Thank you for bringing our attention to it. You can vote or comment on this issue here. I have updated your Telerik points.
The fix for it will be included in our next release at the beginning of March. 
I hope this time frame is ok for you. 

If you have any questions do not hesitate to contact us.

Regards,
Yoanna
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Sam
Top achievements
Rank 2
answered on 24 Feb 2016, 03:02 PM
Thanks for your quick response! Early March works great for me.
Tags
Alert
Asked by
Sam
Top achievements
Rank 2
Answers by
Yoanna
Telerik team
Sam
Top achievements
Rank 2
Share this question
or