UITableView and Another View inside ScrollView - ios

I have UITableView and UIView(used to show image slideshow) inside UIScrollView. The tableview is dynamic and i want to automatically adjust height of table view to show all the cells(and disable scrolling of tableview) and scrollview should show both slideshow and tableview and could be scrollable, I know how to do this with code but i want to know if is possible to do in Interface builder(without using iOS6 auto layout) using previous(iOS5 and early) autoresize method in the xcode size inspecter tab(see image)

I think this is hard to do only using interface builder.

You can set your objects via interface builder. But for maintaing scrolling conditions you need to do it programmatically. Also for table view height to be dynamic you need to be done programmatically.

Related

Issue with Autolayout and StackView while using ScrollView

I a trying to create a UIScrollView that fits exactly the contents of its subviews. I do this with a StackView and the scroll view's height is determined by how much content there is in the stack view. Within the stack views, there are views that contain an UIImageView and a UITextView
The UIScrollView starts below the title view, however every time I want to add another view (which it should scroll when the content is bigger than the actual frame) there is an issue with the scroll view's Y position. This works perfectly if I only add UILabels and UITextFields, using the same procedure
How can I do it so I can programmatically add views on the stack view that includes an UIImageView and a UITextView, just as the View Controller with labels and textfields does.
You can download my app project at the following url
https://github.com/francisc112/DescriptionWithImageApp.git
Instead of a scroll view why don't you use a table view and create a custom cell with the stackview and its contents inside the cell and you can dequeue the same cell for adding multiple information.
I was not able to open your project
So I Tried opening your StoryBoard and Re-Viewing your constraints Applied , here is what I have Done Please check in following Link
Link - https://drive.google.com/file/d/1D-dzKsSqpx7dWsI5fYRdAfCMY_vENoIR/view?usp=sharing
View Hierarchy
Note - For such output I will prefer using a TableView instead of StackView as Same output can easily be achieved using TableView

How to make a Horizontal and vertical scrolling TableView in iOS using storyboard?

here is my design structure
I was wondering about creating a horizontal and vertical scrolling tableview. I have tried a tableview inside a scrollview but I failed miserably. What to do?
I use swift4 but I wanted to do in storyboard.
The nature of content is like an excel sheet with lots of horizontal and vertical scrolling rows and columns of data.
Actually you can do this using a hack. Put the tableView inside a scrollView. Then you should give a dynamic width to the tableView by specifying a width in storyboard for tableView or any child view of that scrollView(So we get the horizontal scrolling).You have to adjust some constraints depending on your requirement
Mine worked fine but as many users have said try a collection View if its easy
Note. There is a default scrollView within a tableView, So adjust your height of tableView in a way so the scrollView of tableView work and not the parent scrollView, while scrolling from top to bottom
Instead of using TableView try using collection view, there you can use horizontal and vertical scrolling using storyboard?
Try to use collectionview instead of tableview.
If your requirement demands use of tableview anyhow, then you can use tableview within scrollview.
In tableview within scrollview approach, you need to distinguish your parent scrollview as well as tableview's scrollview. Try to differentiate parent scrollview and tableview's scrollview with different tags. Because both scrollview will call delegate methods of viewcontroller, if implemented. Just check tag of scrollview in all delegate methods of scrollview and perform action accordingly.
As per my understaing you want a view which you want vertical scroll view and horizontal inside it.
So here my suggestion is to use UITABLEVIEW for vertical scrolling and UICOLLECTIONVIEW for horizontal scrolling inside tableview
Both will work fine

UITableView inside UIScrollView - Cell not clickable

I have a problem with a UITableView not detecting touches.
In an iPhone-only app, I have a UIViewController, which containts:
UIScrollView
UIView (let's say a content view)
Some labels
UITableView (last)
The labels have a dynamic height, because they contain some text that I must retrive from the web, so I'm using auto layout.
I'm setting the content size of the UIScrollView inside the viewDidLayoutSubviews method, and I'm doing this by summing UITableView.frame.origin.y and its height.
Here comes the problem: when the labels contain only some words and the UITableView does not exceed the iPhone screen size, everything works ok. But when they grow, and the UITableView gets pushed down, when I scroll down I can't click on the cell anymore. Also, if when loading the view the table is half visible and half not, I can click the visible cells, but if I scroll down, I can't click the others.
I'm using swift 2 and Xcode 7.
Here is an example:
Clickable:
Unclickable:
Do the following thing:
yourView.clipToBounds = true
Now, if UITableView does not appears means your UIView is not same bigger to hold down UITableView.
Make sure that your UIView height is bigger to hold the contents in it and then try to tap on it.
Updated:
If you are using AutoLayout, then do the following thing.
Give the fix height to UIView
Take the outlet of height constraint of UIView
Now, in viewDidLayoutSubviews change the constraint of UIView to UITableView contentSize height.
self.heightConstraint = self.tableView.contentSize.height
Let me know, if this helps!
Adding some info to the #Rémy Virin's answer here:
From Apple Documentation, you shouldn't embed a UITableViewinside a UIScrollView.
Important: You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.
Addition:Solution Since you want to scroll the content above table also, the one solution is place a Header View for the Table and place the Content over there to make it Scroll along the Table View.
If you use Autolayout, no need to specify contentSize to UIScrollView as it will automatically expand by taking the height of its subview.
In your case, increase the height of the Base UIView (content view as mentioned by you) which holds the tableView when the tableView height increases.
UITableView becomes unresponsive when it extends below its container view.

How to implement this view for iPhone

The view I expected is like this image
The main view contains three parts: one label, one webview and one tableview. But the difficulty is their size are not fixed. I hope the webView can auto strech height according its content; the tableView's is similar to webView and its height should be decided by its content.
If webView's height is bigger than screen's height, I want to scroll the whole view not the webView.
I tried many ways but can't get the expected result.
You can achieve by using UITableView add your all component on UITableView cell by using cell.contentView and add table on your UIView.

iPhone + resize UITableView

I have a view in which I have UITableView (grouped style). In the Interface builder, I am resizing the UITableView so that it looks like a small portion in center of the screen.
But when I run the application, UITableView takes up the whole area of screen and does not look like the small portion in center of screen (which I had set in Interface builder).
I tried to resize the tableView programmatically in the viewDidLoad method as tableView.frame = CGRectMake (0.0,0.0,100.0,100.0), but still the tableView occupies the whole area of screen.
Please help.
Regards,
Pratik
Sounds like your table view's got autoresized. Try to fiddle with the autoresizing settings.
If your table view is the main view then it will automatically fill the whole view controller's space regardless of the autoresizing settings. In that case, make an empty UIView as the root view and put the UITableView as a subview of it.

Resources