Open UIViewController inside UITabbar from SideMenu - iphone

My app has UITabBarController and SideMenu for which I am using SWReavealController, so in this Sidemenu there is a list of same UIViewControllers which are in Tabbar, so if I click on one of an item from Sidemenu I want that it should open inside Tabbar.
I tried doing this
tabBarController?.selectedIndex = 2
on click of an item of Sidemenu but it doesn't work, I want a solution for it and please refer to image what I want to achieve in case you don't understand the question.
So currently my code on select of side menu item is
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.revealViewController().revealToggle(animated: true)
self.performSegue(withIdentifier: "faeFromSideMenuSegue", sender: self)
}

The issue because of you are directly opening TabbarVC2 from side menu that will create a new instance outside UITabbar.
To overcome this issue.
Create a protocol to trigger the actions for Tabbar selections
Close the SideMenu when click on SideMenu's TableViewCell
Along with that call delegate functions that you created to trigger Tabbar actions
Hope this will help you

Related

Xcode build not showing Table Cell

In the interface builder I see:
but in the built running app, I don't see my red text cell:
here's my Main.storyboard TableView in the Interface Build side panel:
it's just a normal table view dragged out from the UI Objects menu onto the Storyboard.
You might be missing the configuration required in NSTableViewDataSource and NSTableViewDelegate methods as follows. You need to set the dataSource and delegate of the NSTableView you just drag and dropped and implement numberOfRowsInTableView method for the class that conforms to these protocols.
func numberOfRowsInTableView(tableView: NSTableView) -> Int {
return 1
}
Note: It would be best if you go through this tutorial which I found helpful for Cocoa development with NSTableView.

How do I to create a custom navigation bar for NSTabViewController in Swift 4

Im developing an osx application in Swift 4 to be displayed in the menu bar and call a popover when clicked to display a number of different views.
My structure in Storyboard is:
NSView > Container View > Tab View
This lets me maintain a top menu bar while being able to change between tabs.
I have hidden the buttons in the NSTabView and have managed to change between views on load using the following code:
import Cocoa
class TabViewController: NSTabViewController {
#IBOutlet weak var theFirstTab: NSTabViewItem!
override func viewDidLoad() {
super.viewDidLoad()
changeTab()
}
func changeTab() {
let theTabView = theFirstTab.tabView
theTabView?.selectTabViewItem(at: 3)
}
}
When I start my application this loads the 3rd tab programatically which is great!
What I want to do however is create my own menu in the parent ViewController to call this function so that the tabs change within the container.
Is it possible to call this function from the parent somehow?
Ive searched all over for a solution to this problem and am so close but hopefully someone here can help me. I can add pictures of my storyboard if this is not clear enough?
Thanks in advance.

How does the inbuilt Workout app on Apple Watch navigate from main table row to a set of page-based controllers?

I was trying to mimic the Workout app for practise. And I got stuck at figuring out how to do this navigation from these table rows in the main screen to the 3/4 Workout starting screens which are page-based and seem to be hierarchical, with a back button on top left. They are most certainly not Modal as they do not appear from the bottom.
- - ->
However I did not find any way to connect a row to a set of page-based interface controllers with push segue.
This is what I tried:
1- presentController(withNames:, contexts:) which presents the page-based layout MODALLY.
override func table(_ table: WKInterfaceTable, didSelectRowAt rowIndex: Int) {
let controllers = controllersForExercise(categories[rowIndex])
presentController(withNames: controllers, contexts: nil)
}
func controllersForExercise(_ exercise: Exercise) -> [String] {
// Returns a bunch of Identifiers (from Storyboard) as [String]
}
2- In the storyboard, I connected the table row to the first of these page-based interface controllers by a push segue, and then connected that controller to the other three page-based interface controllers sequentially using nextPage segue (relationship).
This did not work. It just segues with the back button on top left but showed only the first interface controller, not the other three as page-based controllers.
I am assuming it is happening because table row selection makes it a hierarchical navigation while this is a page-based navigation, and the two cannot be mixed according to Apple.
So I am baffled about how Apple manages it themselves. Any clues?
OBJC:
+ (void)reloadRootPageControllersWithNames:(NSArray<NSString *> *)names
contexts:(NSArray *)contexts
orientation:(WKPageOrientation)orientation
pageIndex:(NSInteger)pageIndex;
SWIFT:
class func reloadRootPageControllers(withNames names: [String],
contexts: [Any]?,
orientation: WKPageOrientation,
pageIndex: Int)

Unwind Segue Navigation Bar Button Xcode 8.0 Swift 3.0

I want to create an app in Xcode 8.0 that lets the user press a bar button item in the navigation bar. Once this button has been clicked an unwind segue will take place whilst also printing, "helloWorld" to the output section at the bottom of Xcode. I have successfully created an unwind segue using:
#IBAction func unwindToViewController (sender: UIStoryboardSegue){
}
I then linked this to the bar button item on the navigation bar so that when I tap the bar button item on the navigation bar the view disappears downwards.
I am trying to simply print("helloWorld") onto the output section at the bottom of Xcode when I press the done button but nothing appears on the output section. So far I have:
#IBAction func add(_ sender: AnyObject) {
print("helloWorld")
}
in the View Controller Swift File for that View Controller.
For unwind We need to remember only two points
1) We need to put below method into Destination ViewController.It is a place where we want to navigate to. Here method name can be different but arguments matter a lot.
#IBAction func unwindToDestinationViewController (sender: UIStoryboardSegue){
}
2) Go to the Source viewController from where you want to go back. Now click on unWind button on top right and Control-Click and set outlet to the Back button(Example)
Kindly check this post on stack overflow. This is a duplicate of below post.
You can find the answer in the given below link.
https://stackoverflow.com/a/39916477/2894335
This Blog gives a very nice introduction to unwind segues. article link here.
Try the following tutorial will fix your problem and help you to understand more about how to perform unwind segue...
https://www.andrewcbancroft.com/2015/12/18/working-with-unwind-segues-programmatically-in-swift/#identifier
http://ashishkakkad.com/tag/uistoryboardsegue/
Hope this helps...

Configure destinationsViewController based on selectedRowAtIndexPath

I got no code because im very confused. I got a UITableView, the user can create cells by naming. The cells all segue to the same UITableViewController, so far i segue the cell.textlabel?.text to the next UIViewController so they differentiates based on the name. On the destinationViewController i want the user to be able to create a deck of flashCards. These decks of flashCards should off course be connected to their respective UITableViewCell. Anyone know how you achieve such behaviour? Or a place were i can ask a question as such.
App example.
UITableViewCell (cell.textlabel?.text = DogsBreeds) ->(Segue)-> UIViewController (Containing the users customised deck of dogflashCards)
UITableViewCell (cell.textlabel?.text = HorseBreeds)->(Segue)-> UIViewController (Containing the users customised deck of horseFlashCards)