How to use UITableView.ScrollPosition in tableView in swift? - swift

I want to increase the font size of the text if it's in the middle of the screen while scrolling in a table view.

You can use the scrollViewDidScroll delegate method and then change the text size if the contentOffset.y of the tableView is equal or greater than half of your screen height.

Related

UITableView with dynamic height inside UIScrollView:

I have a screen with UINavigationController and UITabBar.
The UINavigationController screen is a UIView (in figure below, in red), that haves an image in the top and a UIScrollView (in figure below, in green). The UIScrollView have two UILabel ("Some text") and a UITableView that DO NOT ENABLE SCROLLING.
Every time the list become bigger, i need to enlarge the tableview height, dynamically. At the same time, I think I need to enlarge the UIScrollView. See the image below:
How can I define the dynamical height to UITableView and UIScrollView?
My goal is: Every time the list become bigger, the UIScrollView become bigger too.
My environment:
My UITableView DO NOT ENABLE SCROLLING
I am using XCode 4.6 and the view is a FreeForm
My view is using AutoLayout
I tried to do this setting just the UItableview height, without success.
How can I do this?
You can calculate the height of table view bin the method
heightForCellAtIndexPath:
in this method you pass the height of each row in this you can calculate height by creating a globale variable and in this variable add the row height each time.
or you can find it by having no of rows * height of a row in height of a row is constant.
may this will help you.

table view with both horizontal and vertical scrolling in iphone

I want to create a table view with both horizontal and vertical scrolling. The content in each row will be label with text. The horizontal scrolling should there when the label size increases the width of the table view. (ie, I dont want to show label's text like "abcdefg...") Is it possible?
Set the UIScrollView contentSize property through code and make sure that UIScrollView contentSize property will have the same height but it would have a greater width than tableView.
OR
You can use an UIScrollView and then inside add the UITableView. This UIScrollView will have the same size that your UITableView have now, but the UIScrollView contentSize property will have the same height but it would have a greater width.
You can use an UIScrollView and then inside add the UITableView. This UIScrollView will have the same size that your UITableView have now, but the UIScrollView contentSize property will have the same height but it would have a greater width.
see UITableView scroll both vertically and horizontally
and https://github.com/alekseyn/EasyTableView
use the following may it work for u.....
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation==UIInterfaceOrientationLandscapeLeft || interfaceOrientation== UIInterfaceOrientationPortrait);
}
also make changes in inteface builder to adjust size and width

iPhone UIScrollView how to properly zoom the view? Currently it's height is not adjusted properly

I have a UITableView within a UIScrollView. It took me quite a lot of work to make it work.
The tableView is 640x350, I use the scroll view to scroll from one end of the cell to the next.
The scroll view is 320x350.
The scroll view's content size is 640x350
I'm running into this problem:
if I set scrollView's minimum zoom scale to 0.5, the tableview's width now fills the screen, but it's height is only half the screen. I would like the tableview to show more rows when I zoom out to 0.5.
First of all I would like to understand if this is the correct behavior, or the result of my tableView's content size and frame manipulations. The tableview has all springs and struts set in interface builder and should fill the frame available. This is my first attempt at zooming in months, and I don't remember how it works with zooming.
Can someone help me understand where and what do I need to adjust?
As far as I understand, I need to put the code into scrollViewDidZoom: that will manipulate the tableView's frame and content size.
PS. I"m returning the tableview from the viewForZooming: method of UIScrollView
What you are trying to achieve is pretty hard.
Solution 1 This solution uses the exact setup you have (UITableView inside UIScrollView).
You say that when you set the zoomScale to 0.5, you want your table view to fill the scrollView vertically. At 0.5, your table view must be 640x700 in order to fill the UIScrollView as you wish. For this to happen, on scrollViewDidZoom: you must resize the frame of the table view to 640x700
- (void)scrollViewDidZoom:(UIScrollView *)scrollView
{
// No matter what the zoomScale is, the tableView will be zoomed accordingly
// Only zoom the height of the table
tableView.frame = CGRectMake(0, 0, 640, 350 / zoomScale);
// Also, update the contentSize
scrollView.contentSize = CGSizeMake(640, 350 / zoomScale);
}
If you run the code above for zoomScale = 0.5 you will get a frame size of 640x700.
This only changes the frame of the table and doesn't change the heights of the cells. This means that as you zoom out, you will also see more cells in the tableview.
Solution 2 Use only UITableView
UITableView is a subclass of UIScrollView. This means it has the ability to zoom and scroll around.
Start with a UITableView with the size that you want on the screen. Then, after the content is loaded modify the contentSize and make it wider than your frame width. This should enable horizontal scrolling.
However, UITableViewCells have their frame set automatically to the width of the tableview frame. You can bypass this by using a custom UITableViewCell, with clipsToBounds=false. Inside it you will insert a UIView with the frame set to the width&height you desire and with no autoresizingMask. When the tableview will resize UITableViewCell frame, this will not affect your inner UIView.

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. :)

iPhone - How to change the cell height of a tableview when touches it

In my table view i have different size of cells. Each cell has just some text.
When a user touches a cell, i want to increase the height of the cell and add some buttons at the bottom of the text.
Can some one tell me how can I increase the size of the cell height and add some buttons at the bottom?
Can you animate a height change on a UITableViewCell when selected?