tabbed navigation in tableview section header - iphone

I'd like to mimic the behavior of profile page of pinterest app.
You can tab on Boards/Pins/Likes(tableview section header) and, tableview changes accordingly.
Below are screenshots to illustrate this.
Suppose I can create each of the tabs(boards/pins/likes) in separate viewController.
Also suppose I want to reuse the code of each viewController because other views(such as 'following' tab on the tab bar) look very much like one of them(boards/pins/likes).
How would I share a table header & table section header and also separate codes enough so that I can reuse bulk of them?
Basically, I have two viewControllers with tableview.
Now I want to create a new viewController with a tableView header/section header that user will tab to see one of the previous two viewController's view.

I don't think the tab appear in Table Header, instead it might be a view subclassing UISegmentedControl. If you want to reuse it you can create the interface in xib file and link it with your view controller
try check this github project https://github.com/rs/SDSegmentedControl for custom UISegmentedControl

Related

Difference between table view controller and a table view placed within a viewcontroller

I am making an app and would like to direct my user once they log in into their dashboard, I have seen some apps display things in what seem like a table view controller or a view controller with a table view. I would like to display the logo up top and then a table displaying their username then about 4 more rows displaying other info then at the bottom a tab bar. What would be the best way to go about this?
any advice welcomed. If relevant I am using swift, Xcode7 and parse to handle my users
Use a UITableView. This a bit more customizable in terms of Storyboard layout. You can place UIImageViews, toolbars, and other elements all over your UIViewController. You can then put a UITableView in the exact place that would work for you, with the dimensions you need.
Of course, you could always use a UITableViewController. You could embed this controller in a variety of combinations, which would let you add tab bars or navigation bars.
The only real difference in implementation is that you have to remember to explicitly write the delegate and data source methods when using a UITableView.
For your case, I would pick whatever seems easiest to implement in your case. Probably a UITableView in my opinion.
Some differences between UITableViewController (TV) and UIViewController with TableView (VT) I know:
You can add other controls into VT and pin it to anywhere you want. TV can't do that.
You can add many same group of controls without add constraints with TV. VT you have to add constraints.
You don't want to worry about scrolling in TV with many group of controls.
With TV you can create static table cell but you can't with VT. Static table works on TableViewController only.
In your situation, I use UITableViewController with static table to achieve that.
Hope this can help.

PullRefreshTableView editing

I have a PullRefreshTableView from leah(https://github.com/leah/PullToRefresh). Problem with this, as soon as I implement this. The view is changed to a tableview by doing this:
#interface news : PullRefreshTableViewController {
So I can't add any toolbars or navigationcontrollers to the top. Does someone know how I can add a toolbar to the top of the screen in combination with the PullRefreshTableView.
Thnx!
You know when you have this standard UINavigation template when you create a new project with xcode? Gives you 3 ( right ? ) nib files, 1 with the window, 1 with the mainview / navigation controller and the other one contains the tableview.
Open the one with the tableview. Select the tab that looks like this:
It will allow you to change the class it creates when the nib file is loaded. Change it to the PullRefreshTableView and when you launch the application a PullRefreshTableView will be created instead of a normal table view.
You can hook this up as an Interface Builder outlet exactly the same way you would hook up a normal table view. Its a subclass so it should even be able to be connected to the normal tableviewcontroller that is included in the template.
If you have done this, you should still be able to add the toolbars like you did with a normal table view. Also, if you want to have a toolbar on your iphone screen it shouldn't be a subview of the Tableview, but a container view should contain both the toolbar and the tableview.

split UITableView in iPhone

In the amazon iphone app home page there is a grouped table view that has two cells on one row. How can I recreate this?
I would expect, that it is one cell, that shows different information. You can find a lot of informations about customizing UITableViewCells
iPhone Tutorial: Creating a custom Table View Cell
Customize that UIViewCell – Part 1: Using Interface Builder
Go to your interface builder, click on your TableView and press command+1 to bring up the Table View Attributes. There on the first section Table View Style. Change it to "grouped".

how to manage a stack of UITableViews without a navigation controller

I am new to iPhone development, and I am working on modifications to an existing iPhone app. The high-level overview of the issue is this.
I have a button displaying a pop-up containing a UITableView.
I'd like to click on a menu item and display a second UITableView with sub-items, including a back option. If the user clicks back, they go the original UITableView. If the sub-item has additional sub-items underneath it, it should (when clicked) launch another UITableView with these options. There is also a back button as a menu item that will allow the user to navigate to the previous menu displayed.
The challenge here is that I am not using a navigation controller. the original developer only wants to add UITable Views to the stack, add transitions between them as you go from one menu to the other. Most of the tutorials I have seen and tried utilize a navigation controller and Interface Builder to associate the UITableViews.
Right now, I have an XML data source populating the menu, and when I click on a menu item, the titles change correctly, but still uses the same UITableView to display the options - this has consequences of course, as some of the sub-items may not fit on a screen.
any thoughts on how this can be done? I can post some code if necessary, although I think the general description should be able to ring a bell with one of you smart guys!
This can be done in numerous ways.
I haven't done this first one, but you can probably create a UINavigationController and set its view to the appropriate frame (inside the bubble) hide the navigation bar and set the action of your back button to pop the current view controller.
Another method is to have multiple tableviews on one controller, the delegate and datasource methods have the UITableView as an argument so you can distinguish them when setting the height of your rows, headers etc and when returning a UITableViewCell.
The way I've chosen to deal with such configurations is to have one UITableView and have only the datasource change. When you reload, insert, delete rows or reload the whole table, you can change anything you want depending on the current datasource level. The easiest none animated way is to reload the whole table.
a) If your "options" go off-screen height wise (you want fixed height) table change the - (CGFloat)tableview:(UITableView *)table heightForRowAtSection:(NSInteger)section return value
b) If your "options" go off-screen length wise either make your cell's default textLabel flexible: cell.textLabel.adjustsFontSizeToFitWidth = YES; cell.textLabel.minimumFontSize = 14; or have custom cells (lookup subclassing UITableViewCell, which is recommended) for each datasource level.
If you subclass TableViewCells remember to have different dequeue cell identifiers for each level, so the table doesn't provide you with another level's cell class.
For the "stack" of tableviews or datasources, you can have an NSMutableArray with addObject for push and removeLastObject for pop.
For animations, UITableViews can animate their rows/sections for 3. (see documentation for insert, delete, reload - Rows/Sections UITableView class reference), for 2. you can even have UIView (if not CoreAnimation as Grimless suggested) animations, that move the current tableview to the left (setFrame:) and the next tableview from the right (setFrame offscreen before animation and then in place in the beginAnimation-commitAnimation clause), but make sure you add the tableviews in a container view (the bubble interior) that clips its subviews.
Oi. This is gonna be a tough one. My suggestion would be to maintain your own stack implementation. Then, use CoreAnimation to add/remove UITableViews from your main view controller to get animated effects. So whenever the user clicks on an element in the current table view, the appropriate controller creates a new controller and table view, and then your custom navigation controller pushes the old one onto the stack, removes the old table view from the main view, sets the new controller as the current one, and adds the new table view to the main view. Kinda messy, but I think it will work.

UITabBar functionality without UITabBarController

I have this problem, I've got a navigation-based application, and on the one of the detail view i need to have UITabBar, which will display some UITableViews. Since apple documentation says "you should never add a tab bar controller to a navigation controller" it make quite a problem, i've found this sample: link text, it's working, but after picking one of the table view, the UITabBar disappears.
don't use a tab bar controller, just use a UITabBar inside your controller view and manage the switches between UITableViews yourself, either by:
loading up as many table views as you
need and stacking them (bringing the
one corresponding to the tab bar hit
to front)
switching a single table view's data
source and delegate among a few
helper objects - one per tab in your
bar. When the user clicks a tab, reset the single table view's data source then instruct it to reloadData
Now that you are not using a TabBarController for showing the tableviews (as mentioned in the link), have you made sure that the table views or any other views you are adding when a tab is tapped are correct size?
You are adding a subview or bringing it to top so the table view is probably covering your tab bar.
When they are choosing an item from your table view are you pushing a new view controller onto your navigation controller? If so, you will leave the tab bar behind!
Without some hefty hacking, you generally can't do what you're trying to do. What you'd have to do instead is to deal with adding new views yourself when a table cell is selected so the new views you add don't overlap the tab bar at the bottom. Though this will probably break the navigation controller.
Though my advice is to rethink that part of the app's ui so you don't care that the tab bar vanishes. Sorry :(