iPhone: How to Place a Scrollview Inside of Tableview Cell - iphone

I want to put a scroll view inside of the table view cell. I have a number of buttons in one cell of table view and I need to scroll that cell to show the appropriate button.

If you want to use a vertical scroll view then I wouldn't suggest you doing it because, as TechZen wrote, there will be a mess in this case.
If you want the inner scroll view to scroll horizontally then it might be achieved by 2 ways:
Implement a custom table view cell that will include a scroll view inside it.
Add a scroll view as a sub-view to your cell that you will return from tableView:cellForRowAtIndexPath: method.
I suggest you to use the second approach.
There are plenty of examples online. Usually the sub-views are labels or image views, but it is not complicated at all to add a scroll view instead...

I don't think you can do this. It would require nesting of scrollviews which isn't really supported.
Even if it was, it would be very difficult for a user to know which scrollview they were hitting with their pudgy finger. Remember, you don't have the one pixel precision of a mouse on the iPhone. You have an area of at least 15x15 pixels. You don't have a scroll bar but instead just drags anywhere on the screen.
Instead, you should use a master-detail pattern. Selecting the cell in the tableview pushes a detail view which has the scroll view with all the buttons.

Why do you want to do it like this?
I think the best idea is to draw your table view manually above your uiscrollview. I did it, and it works. It just takes more effort and drawing accuracy. But that takes a lot of time. :)

Related

scrolling entire screen with UIScrollview and UICollectionView

I am trying to build this view where I have a UI Image view with some labels below it. And then Below this I have a Collection view which has a few items. I am struggling to figure out how I could have this view such that the whole screen keeps scrolling up once i get to the collection view.
Right now, the image view and the labels below scroll, but then the collection view only scrolls within its constraints. What I want is the entire screen to scroll up so the collection view items fill the screen up. I have seen several other replies to similar questions but am unable to follow it.
Can someone help with what I am doing wrong here ?
For the best practice on mobile programming, you should not have a scrollable view in another scrollable view. If you do so, you will have the problem as you described that your child collection view starts to scroll while other elements like your imageview and labels stay there.
To achieve your point, you can simply use a collection view and have custom cells. Now your entire window has only one scrollable view so it looks better. Then you are basically have different cell types. On top you have a collection cell as image, then you have few collection cell as labels, and so on.

How to lay out scrollable iPhone view

I need advice on the most pragmatic way to layout the following view. As you can see from the image attached, I have a static logo and text that appears at the top of the view, followed by a variable number of items.
Initially, I was going to use a TableView for the variable number of items, that way I would be able to load any given number of cells at runtime.
My problem is that if I drop a tableView onto this view below my static logo and text, when the user scrolls, the static logo and text will remain fixed. I need both the static logo/text AND the tableView to scroll up.
My next inclination is to use a scrollView, inside which I would place my tableView and static logo.
Is this the most pragmatic way to approach the problem? If so, will there be usability issues when scrolling the scrollView vs scrolling the tableView? In my mind this could get messy.
Any advice on the best way to approach this is greatly appreciated.
Using a table view inside of a scroll view is a bad idea and warned against by Apple in their docs. Basically the internal gesture recognizers can conflict and create a clunky user experience. The best path forward would be to go with the tableview (which is a subclass of scroll view) and have two different kinds of cells– one for the logo and one for the repeating contents at the bottom. Make the first cell the logo and adjust the table view's settings to format it to your heart's content.

How to implement smooth scrolling using both a UIScrollView and an UITableView?

Is is possible to implement smooth scrolling using both a UIScrollView and placing a UITableView at somewhere starting in the middle of the screen? The UIScrollView contentSize is elongated to accomodate the additional height of the UITableView. The UITableView should be able to contain unlimited and unknown number of rows. Scrolling the entire view downwards will cause the upper non-tableview portion to first disappear and then it scrolls down just like a regular table view.
Put it in another way, I'd like to implement a table with some fixed content before the top row. Think of it like a "header area" for the tables, scrolls up and giving way to the entire table rows.
I probably know that I can implement a TableView and programatically make the first row to contain some fixed images. In this way, it will work as expected. But which is easier to implement?
You really don't want to put the table in a scroll view. When the user scrolls on the table it will not move the underlying scrollview so you won't get the effect you are looking for.
Implement viewForHeaderInSection instead and pass in the view you want to display above the first row, or set tableViewHeader.

UIScrollView always bounce upwards and does not show scroll bar in iphone

This is probably simple but I do not seem to get it to work. I have a view and inside it I have a scroll view and inside it I have a view with some labels and a button. the height of the text inside the labels changes according to some condition so I need to scroll down to see it. But whenever I try to scroll down it bounce back up without giving me a chance to view the rest of the view.
Basically, I want when I scroll down, the view to remain down as it normally should. Besides I do not see the scroll bar at all when I'm scrolling.
I know I probably do not understand how scroll views work, so I'd appreciate any help to explain to me the behavior of scroll views.
P.S. I built my whole view in a nib file and this specific setup That I mentioned at the beginning is based on a suggestion from one question I read here.
Thanks, Mohsen
you need to set content size of your scroll view
[scrollView setContentSize:CGSizeMake(360,1000)];
you can make the content size dynamic as per your calculation.

TableVIew Problem

i i want to activate scrolling vertically through programming for 2 UITableview at sametime?(one table view length 160,another one has 160).is it possible ?In one Viewcontroller's view i have scrollview, on that i have two tableviews(instead of one,like two column)..how can i scroll vertically both at same time?any help please?
If you want to implement 2 separated and round-rected columns then it might make some sense.
In any other case just use one UITableView and separate each cell visually (the left half will display the data for the first column and the right - for the second).
If you still want to have 2 separate table views and have them both scrolled simultaneously then get rid of the containing scroll view and implement the UIScrollViewDelegate as was already suggested.
Something like this:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
self.leftTableView.contentOffset = scrollView.contentOffset;
self.rightTableView.contentOffset = scrollView.contentOffset;
}
I think that this code should do the magic...
Don't forget to set the view controller to be the delegate of both table views.
I don't really get it but a table View on top of a scroll View will create problems. Because, when users scroll, both of the views will try to get the interaction of the user, and they can take turn to get that interaction randomly.
Can you post a picture, or clearer description of what you want?
If your next question is "how do I make the scroll views stay at the same offset?" -- i.e. you want them to sync vertically -- than I would advise that you abandon the idea of using two UITableViews.
Instead, define a two-column UITableViewCell, which can easily be done with Interface Builder, and use that to give the appearance of two columns.
I think that doing away with neither UITableView’s userInteractionEnabled set to YES, and implementing your own touchesMoved:withEvent: method (maybe also try UIGestureRecognizers) would prove fruitful.
I am guessing that these UITableViews are not used to show plain tabular data but images or other content, and have a different interaction paradigm (e.g., when the two fingers slide separately the two table views scroll in separate velocity & direction). If that is the case you might ultimately want to use custom controls.
But if you just want a 2-column UITableView then as Jonathan said, simply use a two-column cell.