TableView Positioning and Resizing - iphone

what i am trying to make is a view which also has a tableview inside, the table view is to be positioned half the way down the page. At the top of the page there are going to be Images and labels etc, the main issue is getting the tableview at the bottom of the page and also being able to insert data into the table using a plist. I have tried many different methods in resizing and the position of tableViews but of yet nothing has worked. If you have any advice or a tutorial please let me know, thanks

You can try to put your images and labels at top of page into the header view of your tableview. See tableview.tableHeaderView property.

set the position programmatically

tableView=[[UITableView alloc]initWithFrame:CGRectMake(X, Y, Width, Height)];
You can set the position also height and width.

Related

How to make a scrollable view in iOS?

i am looking to create an "options" page for my application and because they are many , the screen of the phone is not enough to show.
So i need the user to be able to scroll down the view to see more options till the last. I know i should use the scrollview , but i dont know how.
All the tutorials i ve found are about scrolling all over the screen , zooming , scrolling from left to right , but nothing on how u can create a simple page scrolling up and down.
How exactly do i do that? Do i make many .nib files and somehow i connect them? Do i make a big .nib file?
Can someone guide me to a tutorial on that?
Use ContentSize property of UIScrollView to scroll what ever area you want. i.e.
take UIScrollView add it on UIView with exist height of iPhone. i.e. max 460.0
So ScrollView frame will be max (0,0,320.0,460.0).
Now after adidng ScrollView to View set ContentSize property to upto scrollable area.
[self.mainScrollView setContentSize:CGSizeMake(self.mainScrollView.frame.size.width, 1000.0)];
UIScrollView *mainScroll = [[[UIScrollView alloc]initWithFrame:CGRectMake(x,y,w,h)]autorelease];//scrollview width and height
mainScroll.scrollEnabled = YES;
mainScroll.userInteractionEnabled = YES;
mainScroll.showsVerticalScrollIndicator = YES;
mainScroll.contentSize = CGSizeMake(width,height);//width and height depends your scroll area
..........
//add subviews to your scrollview.....
[mainScroll addSubview:view1]
............
[mainScroll addSubview:view2]
..............
[mainScroll addSubview:view3]
[self.view addSubview:mainScroll];
Note :: contentSize property determines your scroll
area.Scrolling
enabled only if your scrollview content larger than scrollview height..
You could use a Table View with static Cells, that will scroll automatically if it needs to, much easier. Also with a Table View you can choose to scroll up, down, left, right, set bouncing etc from the Attributes Inspector.
Make only 1 nib file.
give height of scroll view large as you want.
then place your buttons , textfeild on scroll view
There are two ways :
make settings bundel for your app check this Press Me
to make UITableView with custom cells >> it is easy if you use
Interface Builder Press Me

UITableView not scrolling to the bottom

I have a UITableView (on a UIViewController) on which I want to ad an iAd banner on the top, but below a toolBar I already have on the top. I'm trying to shift the the tableView (in reference to the view) so I can locate the banner in the space left blank.
To check it ou, I create an action in which I shift the tableView frame:
-(IBAction)iAdAction:(id)sender{
self.tableViewConc.frame=CGRectMake(0, 94, 320, 367);}
where 94 is the summ of 44 from the toolbar and the 50 from the banner.
The action works correctly but then, I cannot scroll to the bottom of the tableView, when I try it, it bounces back. I've tried to change the height of the tableView in the same action ( 430 instead of 367, for instance) but it doesn't work. I've also tried it on IB, but it doesn't work either.
I feel that I'm missing something but I cannot remember what.
Any help?
Thanks in advance!
Not being able to scroll to the bottom of the tableview is usually a symptom of its height being too large. (i.e. it's cut off at the bottom)
Don't compute the height you need and put those numbers in your code. Just find out what it should be from the view hierarchy. For example, you might compute the height of your table view with CGRectGetHeight(self.view.bounds) - CGRectGetMaxY(self.iAdView), and the view's y origin with CGRectGetMaxY(self.iAdView) assuming that the iAd view and your table view are both subviews of self.view. Or, even better, just use autoresize masks or autolayout to keep the table view the right size.
You can try
self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 44, 0);
I just had this embarrassing scenario where my UITableView would "bounce" but it wouldn't scroll to the bottom. For ME, the problem was that I was dynamically setting the row heights, and my very last cell was getting calculated with a cell height of -115 (yes, negative). Once I fixed that to return a positive number, my scrolling worked just fine.
Even we can achieve the same in storyboard.
Select tableView --> from the storyboard control click on 'add Missing constraints'. That will add the constraint to tableView and View.
That helped me to resolve this issue. Screenshot_Link
Check the number of the row that you can't see.
After in your viewDidLoad, add this method:
myTableView.contentInset = UIEdgeInsets(top: 0,left: 0,bottom: yourCellHeight * rowHeight,right: 0)
I hope I have been helpful

View table size and positioning won't change

I have a xib tableview controller and i can't get the size of the table view to shrink so that i may add additional things before the view(I would like to add some buttons). I try changing the frame in viewdidload and viewwillappear but nothing seams so work. I am using
self.tableView.frame = CGRectMake(0, 100, 320, 200);
but the view remains in place(just under the navigation bar). What am I doing wrong?
Why dont you resize in the xib tableView itself? What's preventing you to do that?
EDIT: Why cant you change the height in xib or x and y coordinates? Attaches image should help you do this easily in IB - (make sure to select your tableView and open the right hand sidebar to get this menu. Once right sidebar opens goto - Size Inspector & here you can do this.
I had the same problem and i realized that my tableView was inside another TableView with its own x and y (so probably i was not able to change it). So you have to make sure that your TableView is a subview of your view or is your main view
Use a UIViewController, drag and drop a UITableView in it, resize as per your wish and there you've got what you were looking for.

Dynamically set UIView size depending on height of grouped table view

Setup: I have a UIView with a scroll view nested within it. Within the scroll view I have a label, uiimage, and a tableview (grouped). The label, uiimage, and tableveiw are populated by a webservice. The last section in the grouped table view contains text that will never be the same and could be as long as 5 characters to 250+. Also, this view is pushed from a basic tableview (so it has a navigation bar. If that matters at all).
Expected: The uiview should extend in height depending on the height tableview extends to. Then I will be able to set the scrollview to accommodate the height I need to be able to scroll.
Problem: I'm not quite sure how to approach the issue. I really only know how to change the height to fixed values, which will not work properly in almost any scenario.
Am I using UIScrollView incorrectly? Do I need to resize the UIView at all?
You don't have to modify your UIView frame size, which has to be the size of your screen. The UIScrollView frame size must also be the same, it represents the part of its view actually displayed.
What must change is the UIScrollView contentSize, which defines height and width for data inside it ;)
You can calculate it using each inside element's height and by adding the correct margin.
Thus, you could have a UIScrollView content size of 320 * 600, which will let you automatically scroll down.
In fact, you have to display your content independently of the final frame size. If you have a content of 500*500, just display it inside your UIScrollView. Then tell it the size of it's content, and it will automatically set scrolling possibilities if needed.
Turns out I had to create a UIView programmatically and set it as the header of the UITableView. It works perfectly now. :)

How do i have different UITextViews on the same DetailView without having scrolling problem?

I have DetailView in which there are three textviews which are showing different informations. is it possible that on whenever i scroll down to read all information. all those textviews scroll like they are one page. i mean they look like one textview. i m doing this bcz i need those information in different fonts. and if there is any other nice approach i can use to show that information? plz tell me.
thanx in advance.
Yes, you can place those three UITextViews into a UIScrollView, set userInteractionEnabled = NO in the UITextViews, and properly set the contentSize of the UIScrollView to cover all 3 UITextField size, then they will all scroll as one unit and the UITextViews won't scroll at all within themselves. (Again: a UIScrollView will not scroll in height / width unless the contentSize property's height / width is larger than its frame property height / width).