WatchOS2 Context Menu not working with BecomeCurrentPage - watchos-2

I setup a watchOS 2 context menu in the storyboard and it works fine UNITL I use the same page with becomeCurrentPage:
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
setTitle("Activated")
self.becomeCurrentPage()
}
If I go to another page, then return, the context menu then works with force touch. Any suggestions?

Related

How to fix new view display after segue?

I just recently started coding again after about four months. There were a few updates in between. When I went to work on my app I clicked on a link and noticed the new view was hovering over the last view and there was no status bar. Just wanted to know what is causing this to happen and how to fix? Thanks
self.performSegue(withIdentifier: "Recover=>SignIn", sender: self)
override func prepare(for segue: UIStoryboardSegue, sender: Any!) {
if(segue.identifier == "Recover=>Connection") {
let navController = segue.destination as! UINavigationController
_ = navController.topViewController as! Connection
}
}
iOS 13 changed the way view controllers are presented by default. If you are using something like
parentViewController.show(childViewController, sender: self)
In iOS 12 the child view controller used to be shown full screen. In iOS 13 it shows up hovering over its parent.
To make it show up full screen, you need to add one line above the show():
childViewController.modalPresentationStyle = .fullScreen.

Conditionally show settings page?

I want to check if the user is a moderator before displaying a certain page in my settings. Here's how my storyboard is laid out:
When the user taps the "Invite users to pack" I want to check if a certain variable is true before pushing the view.
The problem is that if I hook up the cell to the UIViewController to its right then it automatically transitions when the cell is pressed. How would I implement some sort of code like?
if (isMod == true) {
// Show page
} else {
print("ACCESS DENIED")
}
If you're using segue, check it in override func prepare(for segue: UIStoryboardSegue, sender: Any?) in viewClass with tableView. Or you're using code to push (to navigationController), you can check before .pushViewController(viewController:, animated:)

Swift: Trouble getting rid of "dim"

I have been following this tutorial: http://www.totem.training/swift-ios-tips-tricks-tutorials-blog/ux-chops-dim-the-lights
However I have edited it slightly so that I can specify different Segues and also do it programmatically.
The problem occurs when I close the popped up view. When I close it, the background dim stays there:
What I did to the project files:
files: (https://github.com/TotemTraining/DimBackground.git)
1) Deleted the Segue that was there
2) Created an IBAction for the button named clickedButton
3) Created new Segue from first VC to second Named the Segue testSegue
4) Added this code for the IBAction:
#IBAction func clickedButton(sender: AnyObject) {
performSegueWithIdentifier("testSegue", sender: self)
}
5) Changed the prepareForSegue to:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if (segue.identifier == "testSegue") {
dim(.In, alpha: dimLevel, speed: dimSpeed)
}
}
Now, When I run it, it shows the popup the desired way however when I click the close it removed it but leaves the "Dim" there. Can anyone see why?
The view is going to have several segues from it and I only want a few of them to have this "dim" effect.
Edit:
If I take out the if (segue.identifier == "testSegue") so its now:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
//if (segue.identifier == "testSegue") {
dim(.In, alpha: dimLevel, speed: dimSpeed)
//}
}
it works as desired, so is it something to do with that?
It sounds like your unwind isn't getting called in order to dim out. Have you set a breakpoint to make sure? Also, if you are using Xcode 8, there was a weird bug with unwind segue names. They automatically got appended with "WithSegue:" at the end of them, so double check that it is labeled correctly in Interface Builder.

Is Firebase unauth() codes correct?

I use Firebase for my app. When I segue back from a page to Login page and in prepareForSegue to logout the user, the page DOES go to login page but comes back to former page automatically right away. I want to make sure codes for logout are correct. Here are the codes:. Ref_URLBASE is my app ref in Firebase.
#IBAction func backBtnPressed(sender: AnyObject) {
self.performSegueWithIdentifier("toLoginPage", sender: self)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "toLoginPage" {
Ref_URLBASE.unauth()
}
It is likely code in your login page controller causing an autologin if you have implemented keychain access for username/password. Make sure this gets cleared after logout so that it doesn't auto log them in right after they logged out.

Remove tab from TabBarController with different users iOS Swift

As you seen in the picture above, there're one login screen, tab bar will appear after login successfully.
What I want to do is, let say there are two different user such as Admin and Staff, they have different login credentials, the Admin login will show all the tab at the bottom, however, the Staff login can just see the first tab. How could I do that? Any idea or code example to refer?
In login screen you can override prepareForSegue as shown below
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let destinationTabBar = segue.destinationViewController as? UITabBarController {
if (!isAdmin) {
destinationTabBar.viewControllers?.removeAtIndex(adminScreenIndex)
}
}
}
In the code above, you check if the user is admin in prepareForSegue method for tab bar controller. If the user is not admin, you remove needed screen (by adminScreenIndex index)

Resources