I am working on an iphone application on XCode 4.3 using storyboard.
I have created a view and I need it to be divided in two parts. the top part will contain a UIImageView and the bottom part a UItableView.
So I added both to the view using the storyboard interface builder, and set the sizes and positions of the UIImageView and the UITableView.
However when I run the application, the UITableView will take the entire view (it is being scaled to fill the view). I need it just to stay at the width/height I specified in the IB.
Why does the UITableView take the entire view? and how can I make a view with a UITableView be a small part of the view and not fill it?
I hope I was clear
Thanks a lot for any help
edit:
Screenshot of the storyboard section
the top part has a UIImageView and a "Share" Button
and the bottom part a UITableView
The UITableView is taking the entire view and hidding the rest
Another screenshot requested
I am not using storyboard here, just a xib, but it should matter. This is how you should set it up:
Autoresizing for UITableView:
Autoresizing for UIImageView:
Notice the fixed top margin for image view, fixed bottom margin for tableview, and flexible height for both. This will ensure tableview always sticks to the bottom and expands upwards proportionally, and vice versa for image view.
You would want to play around with this settings of your UITableView
I believe the setting is off making it resize. But I might be wrong.
Note: this is a screenshot of my UITableView inside a view controller and it is NOT filling my screen. It may have a different setting in your case. So play around with the values in there.
Related
Im having trouble resizing content inside static cells to fit different iPhone screen sizes.
Looking at the image below you can see that the UIPickerView and Sign In UILabel both did not resize in width.
I've tried adding code to the ViewDidLoad like so
self.signUp.frame = CGRectMake(0,0,self.view.frame.size.width,self.signUp.frame.size.height);to programmatically adjust their sizes but nothing changed.
I also tried adding equal width constraints to make it match the UITableViewCell contentView width and that did nothing as well.
Same issues happens to all UILabels (Membership,Schedule,Method...) and UITextFields (Comments)
This is all occurring in a UITableViewController.
How can I get it to resize?
Apples freeform UIViewController and UITableView are externally useful in this circumstance.
If you design your app in the storyboard, before applying constraints make sure the UIViewController's size is freeform (big square that doesn't match any screen size).
Then add constrains.
When you run the app, the app will resize properly.
I've created a UIViewController in a storyboard using autolayout and it has an embedded UITableView. For some reason there is white space above the table view section. My expectation is that the tableview would split all available space into cells and have cells starting right from the top.
What is causing the table view to add empty space above the first section when using auto layout and size classes?
(See screenshot below, the white space beneath "television" and above "Prototype cells" is the problem)
I've examined the constraints and insets, and cant see anything wrong with them:
UPDATE:
Here's the scene hierarchy
Try toggling the UIViewController property in Interface Builder named:
Adjust Scroll View Insets
If you drag a view into the table view it becomes the tableviews headerview that gives a space similar to what you see. Could this be the issue? Your posted layout looks correct.
Alternativley If you click on the Watch view controller in the hierarchy and switch in the simulated metrics section the top bar property from inferred to translucent navigation bar and back again this seems to move the cells down in the tableview when it is set to a translucent navigation bar
I have a scroll view with a image view inside. I was wondering whether it's possible to have the image inside the image view be much smaller than the resolution of the screen, and somehow be able to stretch it to fit the screen.
Set contentMode on the UIImageView and change its size.
[UIImageView setContentMode:UIViewContentModeScaleToFill];
Check the docs for more informations regarding UIViewContentMode:
http://developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/UIView/UIView.html#//apple_ref/doc/uid/TP40006816-CH3-SW69
Sure, just change the bounds of the imageView.
Am I missing something here?
Your UIImageView is within an UIScrollView I understand?
That would work by adjusting the scroll view plus adusting the image view appropriately. However that is not advisable to do. You will get lost in small errors with annoying effects.
I'd suggest to add an additional UIView that can match the bounds of the screen.
Add that view to the underlying "view" object and use the bringSubviewToFront method.
You could as well make sure that this new UIView is the first subview of the most underlying view object. You could achieve that by manipulating the subviews array structure - which I do not recommend in general wihout having fully understood everythng about the view hierarchy.
You can as well achieve that by adding the additional view at first before adding any other view. (Within IB just make sure that the new view is the topmost in the tree, coming next to the view controllers "view".) And then make it hidden until you actually need it. Then you unhide it. When it is not needed anymore then hide it again and neither delete it nor erase it from its superview.
I wanna do something like THIS in my ipad application, what is the best way to do the followings:
The shadow under the upper bar.
The padding for the papers (top, left, right & bottom)
The background (as a notepad) : please think about the cells: they must still scrolled inside the paper and cropped before reaching to the paper bottom edge.
I'm looking for the optimal solution that avoids overriding as much as possible.
EDIT :
I tried to use UIViewController (with UITableVIew and has the delegate methods) inside UISplitViewController, And I tried adding UIImageView at the top of the table but this view will scroll with the cells and it'll hide when I scroll down. I tried to use viewForHeaderInSection function also for upper shadow (under the bar) but what about the papers bottom edge (what if I put one image including the shadow and the papers bottom edge and has the padding as a background for the UITableView or UITableViewController, and change this image when rotate to the portrait orientation? is this a good and possible solution?)
My guess:
Create the background in an image editing app
Cut 4 images, for header, footer, left and right sides
Create a UIViewController with 4 UIVIews and add the correct images as background
In the middle of all 4 add a UITableView
This way the images won't move and if you position the UIViews with the background properly, your TableView will scroll inside the notebook (assuming you are trying to create a notebook)
If you app is iOS 6.0 only, autolayout will be a great help. Check apple developer video on it to learn how to use this feature: WWDC 2012 Session 232 - Auto Layout by Example
One easy way to do this is from the xib:
1. In xib create image .On image view you can put background whatever you want as a image.
2. create table view above the image view and set table view background color as a clear color.
This will do it.
I have a UIViewController. Within it is a UIScrollView with several views inside it. At the bottom is a UITableView.
This UITableView is dynamic and will display either a small number or large number of rows. Either way, I want the UITableView to be displayed full size so the user can scroll down to the bottom of it using the parent UIScrollView, NOT the UIScrollView inside the UITableView.
I've attempted this by disabling scrolling for the UITableView (this works fine). I've then tried at runtime to expand the UITableView so that all rows can be displayed correctly.
However, this part isn't working. For some reason despite the UITableView being really big, not all the rows are being displayed.
I've expanded the UITableView like this:
CGRect frame = tableView.frame;
frame.size.height = 5000;
tableView.frame = frame;
What have I missed? Is there another view inside the UITableView which I need to expand for all the rows to be displayed?
Sorry if this was a silly question, I've only been using iOS for the last month.
Thanks in advance for any help :)
To clarify, this is a screenshot of the problem.
The red area is the UITableView, so it's definitely the correct size. However, there are supposed to be 10 table rows. There are only 5, even less if I increase the size of the table rows.
What do I need to do to display all the rows? What do I need to resize?
While I see you've managed to get it running, placing a UITableView within your own UIScrollView may mean the table view can't manage its content cells as efficiently as it can when it handles its own scrolling.
But, how can you add your own custom views and have them scroll with the table cells? By making them subviews of the UITableView. If you add one or two subviews to a UITableView, it positions them above and/or below its content, and scrolls them with its own cells.
The screenshot below shows how this looks in the XCode interface editor. Note that the root view is the UITableView, it contains two subviews for the header and footer, and those subviews can contain whatever subviews you need.
I managed to get it to work fine. However, I have no idea what the problem was in the first place.
I moved the UITableView higher up so it was covering the other views on the page. It displayed fine. I then moved it down to determine what was causing the problems, and it started displaying perfectly.
I'll put it down to an error in where I placed the UITableView, as I can't see any other issues.