I'm showing a splitview within a tabbar app. In every split view, master is a UITableViewController (with Freeform size). My Custom tabBar is 1024 x 80 px (always landscape mode), and I'd like to reduce (80-49) px from master & detail that my custom tabbar is hiding from both.
I tried everything, IB, programmatically, in viewWillAppear, with initWithStyle, initWithNib, viewDidLoad, AutoResizing = NO, setbounds, setframe, contentSize... and nothing can make my UITableView to be reduced 31 px!
The UITableView has custom grouped cells, and a backgroundimage. Could be the image the problem?
Any ideas of how can I reduce the size of my UITableView? It has to be the outlet view of File's owner in that viewcontroller? I don't what else to think/do...
Many many thanks in advance, I need to finish this ASAP and that has become a real trouble.
Thanks guys!
I ran into this problem as well. I dont think it is possible with the UITableViewController. I ended up having to create my own subclass of UIViewController with a UITableView as a subview of the viewController's main view. This way you can modify the placement and height within your viewController. One thing to note, if you go this route, make sure to send the tableview the flashScrollIndicators method so that it simulates the behavior of the UITableViewController.
Good luck
I think you should try to set size in viewDidAppear. like i did
(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.tableView setFrame:CGRectMake(self.tableView.frame.origin.x, self.tableView.frame.origin.y, self.tableView.frame.size.width, self.tableView.frame.size.height - 50)];
}
Related
I'm trying to put a big UIImageView on top of a UITableView inside my UIViewController. I read that I should not put a UITableView inside a UIScrollView and so I'm trying to find out how to best approach this.
Right now, in my UIViewController what I have is a huge UIImageView (covering half of screen) and below that I have my UITableView.
The problem is that the scroll only works for the UITableViewCell, but I cannot scroll up so that the image goes to the top and invisible...
Thanks for the help!
Make the tableview the height of the view controller's view then in viewDidLoad say something like:
self.imageView.removeFromSuperView()
self.tableView.tableHeaderView = self.imageView
If you're using auto layout you should move the second line to viewsDidLayoutSubviews
I have a UITableviewController created with storyboard. Now i want to change the X and Y coordinates of the table view (specifically i want to put a little bit down the table view). There's an option in storyboard where i can set this parameter or change the tableview size? I can't find it
I've tried looking in the size inspector but it looks like X and Y parameter are disabled.
The tableview of UITableViewController is main view so we cannot adjust it in storyboard . If u want adjust size try this. In your UITableViewController .
- (void)viewDidAppear:(BOOL)animated
{
[self.tableView setFrame:CGRectMake(x, y, width, height)];
}
It is viewDidAppear not viewWillAppear
I recommend you to drag a UIView to the UITableView. This will create a panel where you can add components and will make the UITableView go down. however, the UIView will also scroll down along with the table cells.
Another option is to create a UIViewController. Drag into it a UITableView. In this way, the tableview is fully resizable.
Create a UIViewController with a Container View. Link the UITableViewController to the container. Now you can resize the table view by resizing the container.
I have added a UIImageView on top of my tableView in storyboard & it works perfectly fine, except that when you scroll down, the imageView doesn't stick to the navigationBar and instead only sticks on to the tableView (revealing the view's background above it).
How would I get it to stick to both the tableView and the navigationBar, and just have the imageView stretch/zoom as the user pulls the tableView down?
This is how it's set up in storyboard:
And this is how I assign an image to it in my ViewDidLoad:
childHeaderView.image = [UIImage imageNamed:headerImage];
Any help would be greatly appreciated. I've tried setting constraints on it using autoLayout but it doesn't seem to let me (they're grayed out, even though I've enabled it for that ViewController).
The problem is that what you did in storyboard is adding the UIImageView as a header to your UITableView.
The proper way to do this is to add the UIImageView at the same level as the UITableView, which mean embed these two views inside a UIView.
Having a UIView as a root view for a view controller is unfortunately impossible for a UITableViewController, and I fear that this is your case. So you may want to replace your UITableViewController subclass by a UIViewController subclass.
EDIT: You'll want to set a fixed height constraint on your UIImageView, and add a vertical space constraint with a 0pt value between your UIImageView and UITableView.
Most of these can be achieved by moving view in IB.
I am trying to change the frame size and position for two UITableViews that are inside a UIViewController that is the rootviewcontroller for UINavigationController.
I want the frame size to change upon a user action. I have everything set up and the following code is executing upon the user's action:
CGRect firstTableFrame = [myTableView frame];
firstTableFrame.size.height = 290;
[self.myTableView setFrame:firstTableFrame];
NSLog(#"%f",self.myTableView.frame.size.height);
[self.myTableView reloadData];
I can confirm that the NSLog outputs 290. However, nothing on screen changes. I found one answer on here that I thought might solve it (unchecking autolayout) for the .xib file but this results in all sorts of other layout issues with my .xib when I run it.
Is there a way to solve this?
This is because the navigation controller has a view which holds the view that you are adding into it (your table views). you have to resize that view too appropriately
I was able to solve this problem by going to the viewcontroller's .xib file and unchecking " use autolayout" in the File Inspector pane. When that is unchecked, the constraints are removed and I was able to resize and reposition the frame programmatically.
When I create my UI in IB I can't do it right because UITableView height not equals its height on the device.
I don't understand why?
Example:
http://img35.imageshack.us/i/20110401111017.jpg
This is happening because the view is being resized when it is pushed on the navigation stack. You can fix this several ways. The best thing to do it setup your nib so it matches the displayed size. You can also remove te autoresize flags from the UITableView. Finally you could programmatically resize the view inside of the view controller's viewWillShow:(BOOL)animated.