开发者

How to horizontally scroll a particular row of UITableview in iPhone objective-c?

I am working on a project where I have to horizontally scroll each row (independently) in the uitableview. Actually I am showing some 开发者_C百科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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜