How to add a ScrollView to my TableviewController class? - iphone

I have a tableviewController class where i am displaying my content in the tableview. Here, i want to add a scrollview below the tableview but i am not able to change the tableview coordinates. My TableviewController is in turn added to a navigation controller. As of now i am able to add the scrollview using self.view addsubview:myScrollView but it is getting added to the tableview. When i scroll the tableview the scrollview is also getting scrolled vertically. But i want the scrollview to be fixed below the tableview and i just want my scrollview to scroll just horizontally. Please help.

It seems what is happening is that you are adding a UIScrollView on top of the view stack and so causing it to rest on top of the UITableViewController instead of beside it. This is not good.
You should consider using UIViewController instead of UITableViewController. You could then subview a UITableView with a UINavigationController and a separate UIScrollView to fit the screen how you want it.
This is a pretty major undertaking, so it will be hard to demonstrate a good answer in code.

What you need to do is make your view controller a subclass of UIViewController, then add UITableViewDatasource and UITableViewDelegate protocol in your header file. If you are instantiating in NIB, toss your Tableview instance and replace it with UIView. You then hook to your FilesOwner as your view. then bring in table view object from the library and hook its delegate and datasource to file owner and you should be good! Hope this work well for you. Work well for me all the time!

Related

UIViewController with tableView or TableViewController in Swift

I would like to have an advice concerning the use of UIViewController and TableViewController.
I would like to do something which is like that:
When I scroll down, the textView is adjusted.
Is it possible to do that with a tableViewController or do I need to use a "normal" UIViewController and place a TableView inside ?
Easiest way, as for me, to do that - it's adding UITextView inside header of UITableView. No matter if it's UIViewController or UITableViewController.
It's very similar to Parallax effect. You can find examples of parallax UITableView in a gitHub, for example you can look on this Parallax demo: https://github.com/runmad/ParallaxAutoLayoutDemo

UITableViewController and sub views

I have a screen where I want to display the details of some product. I'm using storyboards.
I have done this using a tableview with static cells, but static cells can only be done within a tableview of UITableViewController. And the problematic point is that I also want to have a Imageview within this controller. this is not possible as the tableview of a UITableViewController take all the screen size.
So I'm doing the Imageview as a subview of the tableview.
I'm wondering if it is the right way to do it, there are similar issues on stackoverflow but none is corresponding to my use case (storyboard + tableviewcontroller + staticcell + sub view)
Without writing any custom code, you could either:
Put a UIImageView in the table view's header or footer view.
Create a static cell and put the UIImageView in that. Table cells don't have to be uniform length, you could make it taller than the other cells if needed.
You can have your subclass of UITableViewController. After you initialize it take its view (tableView) and add it as subview to some other view controller. This way you can set the frame of tableView to occupy the bottom of the (top containing) view controller. To the same view controller you can add additional subviews like UIImageView and position it on the top. The only problems you will encounter might be related to missing notifications to your UITableViewController subclass (viewWillDisappear, viewDidDissappear, viewWillAppear, viewDidAppear, ...). But you can forward them to from your top view controller. Or you could use methods from iOS 5 to add subclass of UITableViewController as a child view controller and position it as you wish. But this is useful if you plan on supporting devices with iOS 5.0+.
See documentation of method in UIViewController:
- (void)addChildViewController:(UIViewController *)childController __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0);
Use a UITableView as a property of the viewController and add it to vc.view, rather than subclass a UITableViewController, then set its frame as you like
Add the imageView to vc. If you need to put it on top of the UITableView, for example, add it as the TableView's header.

UITableView with in a scrollview not working

I'm a newbie for ios sdk.I've created a sample app.In that app I'm using a tableview and on clicking any cell in the table view i'm pushing a ScrollViewViewController( scrollView with pageControl ) on it.In ScrollViewViewController I'm loading the views which will have each a tabBarController.
In the tabBar there are 5 tabBarItems.And on second tabBarItem corresponds to a viewContoller which has a tableView as subview.
Here the problem is that on the second tabBarItem tableView is scrolling fine in the fist page of the scrollView.But once i swipe to the next page in scrollview and on that page if i select the second tabBarItem which loads a tableView and that tableView is not scrolling.
Please help me.
I've been struck here from more than a month
:(
Thnaks in advance.
This approach isn't really recommended.
The problem being that UITableView inherits from UIScrollView.
It's actually written in the UIWebView documentation:
"Important: You should not embed UIWebView or UITableView objects in
UIScrollView objects. If you do so, unexpected behavior can result
because touch events for the two objects can be mixed up and wrongly
handled."
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html

How can I have a UITabBar instead of a UIToolBar on a UINavigationController?

I have UINavigationController with UITableViewController as the root view controller. UINavigationController has a an optional UIToolBar, but I want to have a UITabBar instead. I don't need a UITabBarControllerbecause I don't want selecting tab bar items to change the view, just the contents of the same view. My app is a basic RSS reader which displays the items in the table view and I want to use the UITabBar to select from 2 or 3 different RSS feeds, refreshing the existing table view in the process, not switching to a different table view.
If I add a UITabBar manually to the UITableViewController (as it seems impossible to do this form IB) it is anchored to the last cell in the table view, so not only is it not usually visible, but it also moves around. I can't seem to find any way to do what I want.
The solution will probably be to use a UIViewController instead of a UITableViewController. This way you can have both a UITabBar and a UITableView, both subviews of your view controller's view.
The UITableViewController class reference describes exactly what behavior UITableViewController provides over a plain UIViewController (such as being the delegate and data source, deselecting rows, etc.) — you should implement all this this so everything works as it should.
You can make the UITableViewController a UIViewController <UITableViewDelegate, UITableViewDataSource>, and then hook it up in a nib with your TabBar. You can find the UITableViewDelegate protocols here. Hope that helps!

Adding a UIActivityIndicatorView to a UITableViewController

How is a UIActivityIndicatorView added to a UITableViewController?
I have tried adding it in Interface Builder and when I drag and drop it onto the view, it just disappears.
I need to show the activityIndicator while the table loads in its data.
If you put a tableview (not a tableview controller) inside another view you can place the activity indicator on top of it. To clarify:
- Plain xib file with a Files Owner and a First Responder
- Add a View (not a view controller)
- Add a TableView into the View
- Add an Activity Indicator into the View
For some reason, the various view controller objects don't like you adding things to them and the tableview object doesn't like you adding things to it. I'm sure that the docs make this really clear somewhere.
You can add UIActivityIndicatorView to your tables in the Interface Builder (IB), but a recommended way would be:
User IB to create and customize a UITableViewCell. Put a UIActivityIndicatorView inside this cell.
Programmatically load your table cells with the customized UITableViewCell nib file.
Programmatically hook up IBOutlets of such UIActivityIndicatorView.