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)
}
7 Answers, 1 is accepted
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

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


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.
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

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