1

I am working on a project where I have to horizontally scroll each row (independently) in the uitableview. Actually I am showing some images in the table view and each row contains images according to their category. So I want to add a horizontal scrolling to each row of the uitableview.

Please give me some sample code or any tutorial link. thanks in advance.

Sanchit Paurush
  • 6,114
  • 17
  • 68
  • 107

2 Answers2

2

To scroll each cell independently, I'd use a UIScrollView within your UITableViewCell.

You'll probably have to ensure that the vertical scrolling of the UIScrollView is turned off, otherwise it may override the vertical scroll of the UITableView.

Also set your UIScrollView content size height to the same as the UITableViewCell height... that should help ensure that your vertical scrolling is still done by the TableView.

Craig Stanford
  • 1,803
  • 1
  • 13
  • 8
  • I want to add have both vertical scrolling of table and horizontal scrolling of cell (row). Please provide me any sample code or any tutorial for this – Sanchit Paurush Jul 06 '11 at 05:11
1

You should be able to do this by placing a UIScrollView inside each table cell. Then place the image inside the UIScrollView.

So in your UITableView, you would implement a method like so --

- (SlideCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

SlideCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[SlideCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

// Configure the cell.

return (SlideCell *)cell;
}

Implement your SlideCell to contain a UIScrollView

#import <UIKit/UIKit.h>


@interface SlideCell : UITableViewCell {
      UIScrollView *slider;
}
-(void)setLabel:(NSString *)t;
@property (nonatomic, retain) UIScrollView *slider;
@end

EDIT : You should review Apple's HIG to see if this is acceptable. Typically, the UITableView is used to show part of the information and you would use a detail view to show more.

Kal
  • 24,724
  • 7
  • 65
  • 65