I write an iOS app in Swift able to cast videos to chromecast. I try to add mini controller at the bottom of the phone screen. Here is a fragment of my code:
...
var castContainerVC = GCKCastContext.sharedInstance().createCastContainerControllerForViewController(self.navigationController)
castContainerVC.miniMediaControlsItemEnabled = true
UIApplication.sharedApplication().keyWindow?.frame = UIScreen.mainScreen.bounds
UIApplication.sharedApplication.keyWindow?.rootViewController = castContainerVC
UIApplication.sharedApplication.keyWindow?.makeKeyAndVisible()
...
When I run this app, I can see mini controller, but when I click on my menu navigation bar button, nothing happens (It worked before I added this code). I don't have this problem with the other two navigation bar button items. I suspect that something gets wrong when I try to assign new rootViewController, but I don't know how could I fix it.
Related
I have a UISplitViewController on my TVOS app written in swift. I'm hiding the menu table view by setting splitViewController?.preferredDisplayMode = .secondaryOnly and I'm showing the menu by setting splitViewController?.preferredDisplayMode = .oneBesideSecondary
Issue here is when i show the menu table view, it is not getting focused and focus still is there on the detail view controller, even though viewWillAppear() of menu view controller gets called and I try setNeedsFocusUpdate(), updateFocusIfNeeded() from viewWillAppear(), indexPathForPreferredFocusedView(..) or preferredFocusEnvironments() is not getting called.
I have tried with tableView.remembersLastFocusedIndexPath = true and tableView.remembersLastFocusedIndexPath = false also and it does not work
Can some one please help
I am implementing an application that uses a UINavigationController. It currently shows 3 views, each a UITableViewController. The first view that is shown only has a title, while the other two have a title and prompt. All segues are created in the storyboard, which is rather straightforward:
The problem: As soon as I animate AWAY from a view that has a prompt, the animation glitches - the title (and sometimes the back button) "fly in" from the bottom, instead of from the right.
Example: https://youtu.be/N-K8piEJ1aY (recording with slow animations turned on)
Here you can see that the animation from first to second view works fine, but from second to third view is glitchy. animating back works.
This issue seems similar to Weird animations when changing NavigationItem prompt . The conclusion in that thread was that this only occurs on iOS 7, I am running on iOS 10.0/10.1, though. The issue occurs both in simulator and on the real device.
Any ideas?
The only solution I found was an absolute hack inspired by an absolute hack inspired by Catalina T. over on this post:
Either in viewWillAppear: on the appearing VC or after calling pushViewController:animated: on the navigation controller (or I'm guessing after calling performSegueWithIdentifier:sender: add the following code:
ObjC
// This is a hack that's because UINavigationBar with prompts is broken
navigationController.navigationBarHidden = YES;
navigationController.navigationBarHidden = NO;
Swift
// This is a hack that's because UINavigationBar with prompts is broken
navigationController.isNavigationBarHidden = true
navigationController.isNavigationBarHidden = false
where navigationController is a reference to the UINavigationController that's doing all the pushing (e.g. viewController.navigationController)
EDIT: It appears now there're other weird animations that occur when popping and repushing a VC, so this answer isn't a true solution. Leaving it up so as to help someone else down a similar rabbit hole.
I've created an app using storyboard. I have few view controllers with navigation controllers. Now in the last of them I have a button, which is opening instagram login view controller (I'm using this library: https://github.com/OceanLabs/InstagramImagePicker-iOS ).
Here's a piece of code:
let loginVC = OLInstagramLoginWebViewController()
loginVC.redirectURI = GlobalConstants.instagramRedirectId
self.instagramLoginViewController = loginVC
self.instagramLoginViewController!.delegate = self
self.navigationController!.pushViewController(loginVC, animated: true)
Then it shows login view controller, I can type in user/password and finally it calls delegate that user was logged in, where I do this:
if(self.instagramLoginViewController != nil){
self.navigationController!.popViewControllerAnimated(false)
self.instagramLoginViewController = nil
}
And it actually pops login view controller, however something strange things are happening from now.
When previous view controller shows up (yes I have it on the storyboard as well as the others) back button doesn't work as it should. On the navigation bar things are changing, but the rest of the screen is not changing until it reaches the very first view controller.
I've checked code inside login view controller from that instagram library and removed that line:
[self.navigationItem setHidesBackButton:YES];
So the back button appears in login view controller too and when I click it everything work. So my conclusion is popViewControllerAnimated is the one, which cause the problem.
How should I fix that?
Damn, I don't know why, but I've changed
self.navigationController!.popViewControllerAnimated(false)
to
self.navigationController!.popViewControllerAnimated(true)
And now it works.. Strange.. I wanted to do it without an animation, but well..
I am having a weird issue with a pushed view controller not taking my previous view controller title and using it as the back button title.
Playing around with it to try to get it to work I got the below code working and the other not working. The self.team.name is a little longer then back but it always defaults to "Back". Any clue why one works and the other doesnt?
Doesnt Work
-(void)viewWillDisappear:(BOOL)animated {
self.title = self.team.name;
}
Works
-(void)viewWillDisappear:(BOOL)animated {
self.title = #"back";
}
As of iOS 7 (I mistakenly said iOS 8 in my comment), if the title of the back button would be too long, iOS automatically show the button title as "Back".
We have an app that contains a bunch of PDFs in its bundle. When the user taps a button or selects a table cell, we want to display the corresponding PDF in a UIDocumentInteractionController.
This works great on my machine, and on most of the test machines, but I have one user who sees no preview on his iPhone. He sent me a screen shot; the controller has pushed its view onto the navigation stack, and has a working "Action" menu in the nav bar, next to the correct file name. But the big space where the PDF itself should be shown is just a dark gray.
That's on a new iPhone running 6.0.1; on his iPad, also running 6.0.1, it works fine; and on my iPhone 4S running 5.0.1, it works fine. "Works fine" means that it pushes exactly the same surrounding details, including the file name and action menu, but instead of a big gray space, there is a working preview of the PDF.
My view controller hierarchy consists of a tab controller, and within each tab, a navigation controller. The same problem exists both from a table view that's several levels deep in the navigation stack, or from an HTML view that's at the top level of the nav stack. The code to present the controller looks like this:
self.DIC = [UIDocumentInteractionController interactionControllerWithURL:url];
self.DIC.delegate = self;
[self.DIC presentPreviewAnimated:YES];
and the only delegate method implemented is:
- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller {
if (curTabViewController) return curTabViewController;
return tabCtrl;
}
This would be returning the current navigation view controller, which I set in tabBarController:didSelectViewController. I can tell that that's working, because the DIC has pushed its view onto the navigation stack, rather than popped up modally.
So. Any idea why UIDocumentInteractionController would be failing to draw a preview on some devices but not others?
UPDATE: I've managed to get this device set up for debugging. The only clue that appears in the log file is this error:
Cannot find preview item for loaded proxy: <QLPreviewItemProxy: 0x1fd67820> -
file://localhost/var/mobile/Applications/22DDE4EB-6FB6-4364-87D6-E3680E1E1A9B
/agilentJAL.app/BuiltInFiles/help/Getting_Started.pdf
I've searched the interwebs, and found this question, but it doesn't seem to apply in my case. I've double-checked the path and it appears correct (and the DIC menu can successfully email the document, open it in DropBox, etc.) Any idea what else could cause this error?
Try access navigation controller instead of tab bar. This solved the problem for me. in documentInteractionControllerViewControllerForPreview:
if let navigationController = self.navigationController {
return navigationController
} else {
return self
}