Alert not showing

8 posts, 0 answers
  1. Sal
    Sal avatar
    58 posts
    Member since:
    Feb 2015

    Posted 29 Sep 2015 Link to this post

    I don't know if this is a bug with the current version or if the documentation isn't correct but I can't get a TKAlert to show no matter what I've tried. I even tried just using a basic example as in the Demo project (which doesn't build in the current version of Xcode with Swift 2.0) below when a button is pressed but the alert never comes up

     

    func settingsButtonPressed(sender : AnyObject) { 
        let alert = TKAlert()
            alert.title = "​Some Title"
            alert.message = "​The Alert Message"
            alert.addActionWithTitle("​Action1") { (TKAlert, TKAlertAction) -> Bool in
                return true
            }
             
            alert.addActionWithTitle("​Action2") { (TKAlert, TKAlertAction) -> Bool in
                return true
            }
            alert.show(true)

    }

  2. Yoanna
    Admin
    Yoanna avatar
    44 posts

    Posted 01 Oct 2015 Link to this post

    Hello, Sal, 

    thank you for contacting us.

    It seems your code for initializing and showing TKAlert is right and I could not represent the mentioned issue with TKAlert not showing up. Here is an example of how I used your code added in my view controller in the test project:
    class ViewController: UIViewController {
     
        override func viewDidLoad() {
            super.viewDidLoad()
            // Do any additional setup after loading the view, typically from a nib.
            let btn = UIButton()
            btn.setTitle("Settings", forState: .Normal)
            btn.setTitleColor(UIColor.blueColor(), forState: .Normal)
            btn.frame = CGRectMake(15, 50, 300, 500)
            btn.addTarget(self, action: "settingsButtonPressed:", forControlEvents: .TouchUpInside)
            self.view.addSubview(btn)
         }
     
        func settingsButtonPressed(sender : AnyObject) {
            let alert = TKAlert()
            alert.title = "​Some Title"
            alert.message = "​The Alert Message"
            alert.addActionWithTitle("​Action1") { (TKAlert, TKAlertAction) -> Bool in
                return true
            }
             
            alert.addActionWithTitle("​Action2") { (TKAlert, TKAlertAction) -> Bool in
                return true
            }
            alert.show(true)
        }
    }

    For this test project I've been using Xcode 7.0 and Swift 2.0. This code results in TKAlert showing up on the screen. If this doesn't work for you, please provide us with some more information about your application so we can provide you with a proper solution.

    Looking forward to your reply.
    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
  3. DevCraft banner
  4. Sal
    Sal avatar
    58 posts
    Member since:
    Feb 2015

    Posted 01 Oct 2015 in reply to Yoanna Link to this post

    It's really strange because the button is firing and showing in the log that it's being tapped and even if I add a breakpoint near the alert it shows it's being created but it just doesn't show. Not sure if it's related to the view, but there's really nothing special going on in this specific view. The view is shown via a segue from another view and then in the viewDidLoad the only thing I do is add the button to the navigation bar like this: 

     

    let settingButton : UIBarButtonItem = UIBarButtonItem(image: UIImage(named: "settings"), style: UIBarButtonItemStyle.Done, target: self, action: "settingsButtonPressed:")
            navigationItem.rightBarButtonItem = settingButton

  5. Sal
    Sal avatar
    58 posts
    Member since:
    Feb 2015

    Posted 01 Oct 2015 in reply to Sal Link to this post

    On a side note, I just added the simple Alert code from above to the the first view controller of my app and the alert showed up without any issues. So I'm not sure if it's somehow related to how the view is being presented (from a segue) or how the view is being built so I'm going to see if I can try and narrow down the actual root of the issue. 
  6. Sal
    Sal avatar
    58 posts
    Member since:
    Feb 2015

    Posted 01 Oct 2015 Link to this post

    So I can't figure out where the issue is, but it does look like the Alert is showing up behind the view because when I opened the sideMenu again I can see the alert behind the view. Maybe it's somewhere in my setup so I'll go through each page and maybe someone can see where the issue is. 

    First in the AppDelegate after the user logs in I replace the view controller with a UINavigationController that has a SideDrawer attached to it as well using this code: 

     

    let storyBoard = UIStoryboard(name: "Main", bundle: nil)
            let dashBoard = storyBoard.instantiateViewControllerWithIdentifier("DashboardVC")
            let navCon = SideNavController(rootViewController: dashBoard)
            let sideController = TKSideDrawerController(content: navCon)
            navCon.navigationBar.barStyle = UIBarStyle.BlackOpaque
            navCon.setupSideMenu()
            self.window?.rootViewController = sideController
            self.window?.makeKeyAndVisible()

     

    In the SideMenuController when a new view is selected I use this code to replace the current view with the new view

     

    let storyBoard = UIStoryboard(name: "Main", bundle: nil)
            var controllerName : String = ""
            //a switch statement is here just to determine the name of the VC to load
            let contentView : UIViewController = storyBoard.instantiateViewControllerWithIdentifier(controllerName)
            let navCon = SideNavController(rootViewController: contentView)
            let sideController = TKSideDrawerController(content: navCon)
            navCon.setupSideMenu()
            self.presentViewController(sideController, animated: false, completion: nil)

     

    That's about it, nothing that looks unordinary to me, the view that I want to show the alert on is just a normal UIViewController with a TableView in it (along with the Delegate & DataSource). As I said I can log the button being pressed and even the Alert being created but when show is called it looks like it's showing the alert behind the actual view. 

  7. Yoanna
    Admin
    Yoanna avatar
    44 posts

    Posted 02 Oct 2015 Link to this post

    Hi Sal, 

    thank you for writing me back.

    From the information you are sharing I assume that this is an issue coming out in case TKSideDrawer is being used for making TKAlert pop. What causes the issue is the fact that every time TKSideDrawer dismisses it brings the rootViewController's view to front and thus the alert is being hidden by it. Thank you for pointing our attention to this issue. I logged it in our feedback portal and you can check its status here. It will be fixed in one of our upcoming releases. I also updated your Telerik points accordingly. 

    For working around the issue I would suggest you to call the alert's show() function right after TKSideDrawer has dismissed. For this purpose you can use TKSideDrawerDelegate's method didDismissSideDrawer

    func didDismissSideDrawer(sideDrawer: TKSideDrawer!) {
             if(*/ your condition here /*){
            alert.show(true)
             }
        }

    I hope this is not a show stopper for you. 
    If you have further questions do hot 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
  8. Sal
    Sal avatar
    58 posts
    Member since:
    Feb 2015

    Posted 02 Oct 2015 in reply to Yoanna Link to this post

    Thanks for finding that issue, but actually I think there's another issue as well when dealing with subviews that are presented using Segue's from a Storyboard. I just removed the Segue from my view that being presented and the Alert wouldn't show up but by manually pushing the view with the navigationController the Alert now shows up on the screen. I didn't change anything on the screen that I wanted to show the Alert, just removed the Segue transition and switched to a navigationController push call and the Alert shows up fine. Maybe something with the Segue is keeping the root view and thus the Alert behind other views as well. 
  9. Yoanna
    Admin
    Yoanna avatar
    44 posts

    Posted 05 Oct 2015 Link to this post

    Hi, Sal.

    Thank you for this update.

    I have tried to represent the issue you have  described, but nothing unexpected happened. It seems like using a Segue in my test project doesn't cause issues with TKAlert. There might be some difference in using Segue between our test project and your project, therefor we will investigate this case further and we will discuss it along with the TKAlert issue.

    If you need further assistance feel free 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
Back to Top
DevCraft banner