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
Related
In my application, I have an UITableViewController inside an UINavigationController in storyboard. What I am trying to do is to have a static tooltip (UIImageView background and an UILabel) right below the UINavigationController so that when my table scrolls, the tooltip will NOT move along with it. Is there any way do accomplish this without using XIB files and just storyboard?
Might not exactly be what you wanted, but if you want a UITableViewcontroller and setting things up using only storyboards:
the easiest way would probably be to either use the navigationbar (make it bigger by choosing "with prompt") or the toolbar at the bottom, both in the attributes inspector of your TableViewController
or (depending on which functionalities you need) you could simply drag out a ViewController and put a TableView inside, then customize everything as you want
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.
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!
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!
I'm developing an iPhone app. I'm using a UITable subclassing UITableViewController. I added a NavigationBar to the view: UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 48.0f)];[self.tableView addSubview:navBar];, now the problem is that the navigation bar scroll down with the table and it's what I want to avoid. Is possible to avoid it using the UITableViewController?
You say
I'm using a UITable subclassing UITableViewController
I guess you are using a subclassed UITableViewController which, naturally, holds a UITableView.
Your problem is caused by the fact, that you inserted the NavigationBar into the UITableView, or, more precisely, into the UIScrollView which is part of the TableView.
Depending on your needs, you have two options:
If you want your app to behave like e.g. Mail (so your TableView will be just one element in a structure of views, through which you can dig down), you should a UINavigationcontroller and make your TableViewController the NavigationController's first view, like when you open the "Navigation based"-Template in Xcode. The UINavigationcontroller will already contain a UINavigationBar, so there isn't much you have to worry about.
If, for some reason, that's not what you want, you will have to create a UIView which holds your UINavigationBar as well as the UITableView. Since accomplishing such a setup with a UITableViewController is known to be rather difficult, you might want to ditch your TableViewController and replace it with a simple ViewController, which implements both the "UITableViewDelegate"- and "UITableViewDataSource"-Delegate. See this post for further help.