I wanted to have a tableview which i should be able to scroll horizontally.So i thought of adding a tableview in uiscrollview and then populating the custom cells in it.
Is it the correct way to do it.I have checked on developer site and it is stated that 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.
Does anyone has implemented such thing.And can anyone help please?
Related
I am trying to add a UILabel along with a UIWebView together in a view controller and want them to scroll together. So to accomplish that, i have added a UIScrollView behind these two views but the UIScrollView is just not scrolling. I am using Storyboard and iOS 7 SDK.
I have seen many questions but they are not of much help. Some are suggesting that i should disable the AutoLayout that i cannot do due to the requirements of my project. What else can i do to make it work? Thanks!
According to Apple's documentation, you shouldn't use UIWebView inside UIScrollView. What you can do is to add your UILabels and UIWebView inside aother UIView and then add this UIview inside the UIScrollView.
Secondly, you have to set the contentSize of the UIScrollView in order for it to work.
You also have to disable the scrolling of UIWebView that is embeded inside the UIScrollView.
Still if your problem is not solved. It is better to just turn of AutoLayout. I have had the same issue and i wasnt able to solve it without disable the AutoLayout.
The documentation for UIWebView states:
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.
You need to wrap the label and web view in a regular UIView. Add the regular view to the scroll view.
So, I've laid out a UITableViewController with two prototype cells, and a view in the TableView's header area. In the header area, there are two views that each hold an icon and a label, Friends and Groups.
It looks all good in the Storyboard Editor, but when the screen actually loads, the images and labels in question are gone. I'm fairly new to iOS, so I haven't run into this before. Here are a couple screen shots to illustrate:
In the storyboard editor:
On the simulator:
Any thoughts? Thanks in advance for your help.
You've implemented the data source methods in your view controller, correct?
If not, UITableView will call a method that its data source implements: tableView:cellForRowAtIndexPath: from the UITableViewDataSource protocol, where you would return the cell to use, in this case the cell with the Identifier that you specified in your Storyboard.
We figured out that this was because the tableHeaderView of a UITableView is really weird about updating/redrawing. It's very difficult to get it to act in any sort of expected behavior.
Instead of using UIImageViews, we used UIButtons. The buttons seem to know how and when to updated and redraw themselves, so that worked.
I have UIWebView inside each UITableView cell.
My UIWebView is simple, it contains only two lines, one is bold, and one is regular.
Everything is working fine, except UIWebView is only loading HTML string when scrolling is stopped, it isn't loading while scrolling UITableView.
How can I fix it?
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.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIScrollView_Class/Reference/UIScrollView.html
And a UITableView is part of a UIScrollView ;)
Can't you get data as a webservice (json or xml) and add UILabel into your tableview ?
Seems to be easier ?
You can create a custom Cell dynamically and attach external/dynamic data to the UILabels.
do anyone have experience with UITableView inside a custom UITableViewCell ?
I had a try and the UITableView in the UITableViewCell looks like that can't respond to user inputs (i.e scrolling).
Before going any further I would like to know if I am wasting my time !
Does anyone have seen something like that around ? Any reference would be helpful.
Thanks
I haven't done this, but I discourage this. This could cause odd things to happen.
In a similar vein, Apple says not to use UIWebView inside of a UIScrollView. The reason is because a web view is a subclass of the scroll view. Nesting them can cause unexpected behaviors. Note that the table view is also a subclass of the scroll view. While Apple doesn't explicitly mention your case, I assume that it is the same idea.
If yo must, subclass UITableViewCell and see what happens. It's not that difficult. Make the cell implement the UITableViewDelegate protocol.
Since the parent TableView responds to the vertical swipe gesture, your child TableView is not going to ever see it. Where should the swipe gesture "go"? It has to go one place or the other, so one of the TableViews will always not behave "correctly". I do think that trying to put a TableView inside a TableViewCell and getting it to work just like a root TableView is probably a waste of time.
I want to zoom the table view to see the contents of the cell???i want to know whether it is possible???any kind of suggesstion is highly appreciated
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.
From UIScrollView documentation
Edit,
May be you should implement something like and alertView when user taps on cell. Present an animated scroll view and there do the zooming.