I have a storyboard with an initial splash view controller followed by a tabbar controller, navigation controllers, and tableview controllers. I need to present an action sheet from one of my tableview controllers.
[UIActionSheet showInView:self.view] does not work, because touches that fall in the tab bar area are not detected, so I must use [UIActionSheet showInTabBar:tabBar].
My question is how can I get a reference to the tab bar or the UITabBarController. Xcode does not allow me to connect a referencing outlet from the UITabBarController or from the UITabBar to any of my custom view controllers (presumably because view controllers on a storyboard are not static objects, but are only created when necessary and related by segues (?), so you aren't supposed to do it that way), but this leaves me with no way to get at the tab bar directly.
What is the right way to do this ?
There is probably a better answer to this question over here:
Storyboard - UITabBarController
In short, pull the root view controller off your appdelegate's window.
I just did the following in my viewWillAppear to hide my tab bar for that particular view:
AppDelegate *ap = (AppDelegate *)[[UIApplication sharedApplication] delegate];
UITabBarController *tc = (UITabBarController *)[[ad window] rootViewController];
[[tc tabBar] setHidden:YES];
Related
using swiftUI i have a lot of Buttons which i need to make only one can be clicked at the same time.
By default in swiftUI you have two or more buttons on a view you can click them all at once
I tried adding the following:
UIButton.appearance().isMultipleTouchEnabled = false
UIButton.appearance().isExclusiveTouch = true
With UIKit we had exclusiveTouch and MultiTouchEnabled but how do we do this with swiftUI?
What is the correct way to solve this application wide?
Update: The use case is simple there is a view with a login button and a register button and now the user can tap both at the same time which i don't want
I am using a vertical page direction on my watch app, and I have a button that opens a new interface, which opens the third interface also from a button, this is done by using the modal view, and in the third interface i am calling popToRootController, because i want to go back to the first interface, but this is not working, have anyone same issue?
You need to use dismiss if you present view controllers modally using presentControllerWithName.
You can use popToRootController or popController if you present the view controllers hierarchically using pushControllerWithName.
You can read more on the Apple Interface Navigation guide.
In your example if you want to dismiss twice, you will have to pass a delegate or closure with the context to your second controller. Then you can call the delegate method or closure after dismiss() on the third controller. The implementation of the delegate method or closure will be another dismiss().
As you know, split view controller hides the master view and displays detail view in full screen mode in ipad. In the full screen mode, ios creates a bar button for the master view on the navigation bar. My question is, is it possible to reposition that button to the far right instead of left? Because my detail view is embedded inside a navigation view controller and there are severals views associated with it. It gets confusing when master view is hidden and the detail view has button to go back to the previous view.
In above screencap, "Category" is a button to display the masterview and "List of Events" is a back button. If you have better way to handle this situation, please feel free to suggest.
Yes, you can do it just send a NotificationCenter.default to the split view controller and change self.preferredDisplayMode in your splitview and coming to moving the category buttom u either can use the right bar button in navigationbar or create your custom navigation bar.
Hope this helps
For those who are having the same issue, I found a very simple solution. All you need to do is assign the rightBarButtonItems with leftBarButtonItems value and set the leftBarButtonItems to nil. Voila, that's about it.
if let leftButton = self.navigationItem.leftBarButtonItems {
self.navigationItem.rightBarButtonItems = leftButton
self.navigationItem.leftBarButtonItems = nil
}
I am working on apple tv app in swift. I need to implement TabBarController. In apple tv application TabBar hidden in change focus but I want to need show TabBar if user change focus in app.
How to do?
Use this method in UITabBarController Class
override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator){
self.tabBar.hidden = false
}
I have the following structure in InterfaceBuilder in XCode:
Tab bar controller
Navigation bar controller
View Controller A
.. push segue to..
View Controller B
However I cannot get the push segue to keep the nav bar and tab bar. It also animates from the bottom like a modal segue.
This is how I start the segue:
self.performSegueWithIdentifier(DETAIL_MEETING_SEGUE_ID, sender: self)
Both VC1 and VC2 have unchecked "Hide Bottom Bar on Push".
In Interface Builder tab bar and nav bar are showing correctly. Also, when dragging a segue directly from a button to VC 2 with push set it works perfectly.
Any ideas?
I experienced a similar issue after embedding tab bar stacks of VCs into navigation controllers. There was a storyboard push segue from VC a to VC b (in a different stack) that was called using performSegue:.
My fix:
Delete the segue in storyboard, then create it again the exact same way. After this the VC b showed the tab bar and the navigation bar as expected.
Filed a bug with Apple Bug Reporter.
I "solved" it by dragging a manual segue from the tableview cell to "View Controller 2". I then gave it the same name as before and made setup in prepareForSegue: as normal. I had to drag multiple segues but it was ok to use the same id for them.
If anyone have a better solution please write it here.