UA-17470720-3

Jump to content


Photo
- - - - -

Tabbar in detail view


  • Please log in to reply
11 replies to this topic

#1 Bounty

Bounty

    Experienced Member

  • STV 4.0 Pro
  • PipPipPipPip
  • 64 posts
  • LocationNetherlands
Reputation: 11
Good

Posted 24 April 2015 - 03:27 AM

I have a plain master detail, visually generated. Using iPad view with spilt view controller.

I'd like to add a tabbar to the detail view, one of the tabs is identical to the original detail view.

When I select another record in the master view, the detail view (inside the tab bar) should represent the details (optionally even switch to the tab if the detail tab is not currently the one selected).

 

For starters, I dragged a new tab bar controller onto the storyboard, and redirected the detail view controller segue from the split view controller to the new tab bar controller. And added a third tab to the tab bar controller that points to the (STV generated) detail view.

 

When I run the app now, the details get shown in the master section on the left, instead of the intended tab on the right. 

 

Tried several options, but here's where I finally got stuck.

 

Attached a demo app, based on the stove core data sample. What I'd like is: (in landscape) when you click on a task ,the task details should show in one of the tabs on the right (tab is named 'STV Details'). If that tab is not currently the selected one, it should display the details if it gets selected. I'd also like the tab to be auto selected if it is not correctly selected, but that might become a second challenge ;-)

 

Anybody who can help out? A short explanation and/or modification to the attached code would be very welcome. Thanks.

 

PS: prefer swift code above objective-c  ;-)

Attached Files


Edited by Bounty, 24 April 2015 - 08:41 AM.


#2 wizgod

wizgod

    I'm what you guys call a User

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 575 posts
  • LocationThe Grid
Reputation: 149
Popular

Posted 24 April 2015 - 08:12 AM

Greetings Program!


I don't think it's going to be an easy task. I tried getting the detailtableviewcontroller via the Storyboard Id and adding an objectssection but that didn't work.

 

SCTableViewController* viewController =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"STVDetails"];

 

I also found this article that looks like it might be helpful: http://ironsheep-ios...-as-detail.html

 

Wg


P.S. I love Swift... talk Swift.. Never too old school to learn yet another programming language. LOL! ;-)


#3 Bounty

Bounty

    Experienced Member

  • STV 4.0 Pro
  • PipPipPipPip
  • 64 posts
  • LocationNetherlands
Reputation: 11
Good

Posted 24 April 2015 - 08:50 AM

Hi Wizgod,

 

Thanks for your reply. I scanned through the article, and guess I need to dig in a lot deeper.

 

Part of my problem is that it is not fully clear to me how STV handles things in the background. As I am not an experienced STV (nor obj-c) developer, it's hard to get a grasp on how to get things done in the first place. I notice that in generating code STV uses runtime attributes and cryptic (generated) outlets and segues, making the whole process even more difficult for a newbee like me.

 

I was hoping this would be a piece of cake (it seems a rather usual scenario to me to have the master show a bunch of records, and the detail the complete data, with tabs to decide the kind of data/extra's you want to do with that data).

 

Anyway, I will dig in the article and try to figure things out. If I do find a solution I will post back, and include coding example if I can.

 

In the meantime, if any experienced developer knows how to get this doen, I'd love to hear!



#4 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 27 April 2015 - 08:11 AM

Hi Bounty,

 

I just downloaded your app and trying to understand it. You say above that you need the tab bar on the detail view of your split view controller, but you have it on the master view on your Storyboard. Have I misunderstood something here?



#5 Bounty

Bounty

    Experienced Member

  • STV 4.0 Pro
  • PipPipPipPip
  • 64 posts
  • LocationNetherlands
Reputation: 11
Good

Posted 27 April 2015 - 08:40 AM

Hi Tarek, thank you for taking a look at it.

 

You are correct, the need is for the tabbar to exist on the detail (right) side. 

 

The attempt code provided did not get the job done (so may be wrong in every way!), but as far as I can see in the code, the tabbar is connected to the split view's detail view controller, as can be seen in the split view's connection inspector )triggered segues). If this is incorrect or misleading, please forget about it. 

 

My wish is to have a list of objects on the left (master side), and a number of tabs on the right (detail side). The detail side should always reflect the selectection in the master side, but leave it open to select another 'tab' to do something else (with a different controller).

 

PS: Examining Wizgod's pointer I found that what I want is not recommended by apple (apple wishes no tab bar inside a split view, just the other way round -- which is not how I want the user interface to behave). Because of the latter I am also experimenting with using a toolbar instead of tabs. This however is causing a different set of challenges (addressed in another topic in the forum).



#6 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 28 April 2015 - 06:46 AM

Hi Bounty,

 

I've created a modified version of our TasksApp sample with the detail view inside a tab bar controller, please find it attached. Here are the modifications I did:

 

a. Inserted a UITabBarController between the original master view controller and the detail view controller and connected it to the UISplitViewController as its detail view.

b. Control-dragged from the UITabBarController to the original detail  view controller to assign it as one of the tabs.

c. Added some code to AppDelegate.m to let STV know about the new tab bar controller and detail view controller.

d. Added some code to MasterViewController.m to automatically activate the STV Detail tab when a cell is selected or a new cell is added.

 

Please let me know if you have any questions.

 

Attached Files


  • wizgod likes this

#7 wizgod

wizgod

    I'm what you guys call a User

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 575 posts
  • LocationThe Grid
Reputation: 149
Popular

Posted 28 April 2015 - 07:01 AM

Awesome Tarek! Opens up a lot of possibilities for another version of my service app.

 

The Completion Steps will need a Done/Cancel button though :-)

 

Wg


P.S. I love Swift... talk Swift.. Never too old school to learn yet another programming language. LOL! ;-)


#8 Bounty

Bounty

    Experienced Member

  • STV 4.0 Pro
  • PipPipPipPip
  • 64 posts
  • LocationNetherlands
Reputation: 11
Good

Posted 28 April 2015 - 07:10 AM

Hi Tarek,

 

Thank you very much. I took a quick look and.. this looks very promising! I will take a closer look tomorrow and try to adapt your pattern into my own (swift) app. 

 

Two things I noticed from my quick observation are that in iphone mode clicking a teak will lead o an empty screen, and in ipad mode clicking on 'completion steps', will popup a screen that can never be existed. These may have another cause, so I will check it out in more detail as soon I can.



#9 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 29 April 2015 - 05:41 AM

I am really happy this was of help to you guys. Regarding the completion steps issues, it's just because I forgot to add a navigation controller for STV to push the detail views on. Please find the new updated mod attached.

 

 

Attached Files


  • wizgod likes this

#10 Bounty

Bounty

    Experienced Member

  • STV 4.0 Pro
  • PipPipPipPip
  • 64 posts
  • LocationNetherlands
Reputation: 11
Good

Posted 29 April 2015 - 05:59 AM

Hi Tarek,

 

This is great!

 

The tabs work as desired in the sample code you provided. I made a similar project in swift, which was easy.

 

I am currently trying to add multiple tabs, where one could select the last used tab (not necessarily the first as in your sample). This is still a bit of a challenge for me, but when/if I get it done, I will share the resulting swift sample project.

 

Thank you so much for sharing your expertise!


  • wizgod likes this

#11 Seth Vanderdrift

Seth Vanderdrift

    Advanced Member

  • STV 5.0 Pro
  • PipPipPipPipPip
  • 108 posts
Reputation: 20
Excellent

Posted 08 June 2015 - 02:05 PM

Ok, perhaps a bit outside the STV questions.  How come the tabs don't display when you run on an iPhone?

 

Google has not been helpful in learning how to have a UITabBarController as the UISplitViewController detail view.

 

Thanks for any insight



#12 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 09 June 2015 - 06:38 AM

Hi Seth,

 

One of Apple's oldest HIG rules is that a UITabBarController cannot be on a detail view of a navigation controller (it has to be a root view controller). This is the case on the iPad, since it's the root on the detail view part of the UISplitViewController, but is naturally not the case on the iPhone. It's worth noting here that many people have tried different solutions to this problem, some of which you can find here: http://stackoverflow...navigation-root






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users