Uitableview 如何在ios6.1中将表视图列表显示为封面流
我对iOS编程还不熟悉。我找到了将图像视图显示为封面流的教程,如链接所示Uitableview 如何在ios6.1中将表视图列表显示为封面流,uitableview,ios6,coverflow,Uitableview,Ios6,Coverflow,我对iOS编程还不熟悉。我找到了将图像视图显示为封面流的教程,如链接所示 但我的要求是将表视图列表显示为封面流。请帮帮我。这里我使用了iCarousel视图。在将SDK(import iCarousel.h和iCarousel.m)集成到应用程序中之后。在所有ICarousel子视图中创建ICarousel视图和集成表视图。这是我的密码 在.h文件中 iCarousel *categorySubView; 在.M文件中 -(Void)createIcarousel{
但我的要求是将表视图列表显示为封面流。请帮帮我。这里我使用了iCarousel视图。在将SDK(import iCarousel.h和iCarousel.m)集成到应用程序中之后。在所有ICarousel子视图中创建ICarousel视图和集成表视图。这是我的密码 在.h文件中
iCarousel *categorySubView;
在.M文件中
-(Void)createIcarousel{
categorySubView = [[iCarousel alloc]initWithFrame:CGRectMake(10, 108, 480, 125)];
// categorySubView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
categorySubView.delegate = self;
categorySubView.dataSource = self;
categorySubView.type=iCarouselTypeCoverFlow2;
[self.view addSubview:categorySubView];
}
-(NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
return 10;
}
- (UIView *) carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view{
UITableView *sampleTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 150, 150) style:UITableViewStylePlain];
sampleTable.dataSource = self;
sampleTable.delegate = self;
[sampleTable setBackgroundColor:[UIColor blackColor]];
return sampleTable;
}
- (BOOL)carousel:(iCarousel *)carousel shouldSelectItemAtIndex:(NSInteger)index{
return YES;
}
- (CGFloat)carouselItemWidth:(iCarousel *)carousel
{
//usually this should be slightly wider than the item views
return 180;
}
#pragma Table view delegate Methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
// cell.textLabel.text = [yourarray objectAtIndex:indexPath.row];
return cell;
}
它的工作精细输出是这样的
这里我使用了iCarousel视图。在将SDK(import iCarousel.h和iCarousel.m)集成到应用程序中之后。在所有ICarousel子视图中创建ICarousel视图和集成表视图。这是我的密码 在.h文件中
iCarousel *categorySubView;
在.M文件中
-(Void)createIcarousel{
categorySubView = [[iCarousel alloc]initWithFrame:CGRectMake(10, 108, 480, 125)];
// categorySubView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
categorySubView.delegate = self;
categorySubView.dataSource = self;
categorySubView.type=iCarouselTypeCoverFlow2;
[self.view addSubview:categorySubView];
}
-(NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
return 10;
}
- (UIView *) carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view{
UITableView *sampleTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 150, 150) style:UITableViewStylePlain];
sampleTable.dataSource = self;
sampleTable.delegate = self;
[sampleTable setBackgroundColor:[UIColor blackColor]];
return sampleTable;
}
- (BOOL)carousel:(iCarousel *)carousel shouldSelectItemAtIndex:(NSInteger)index{
return YES;
}
- (CGFloat)carouselItemWidth:(iCarousel *)carousel
{
//usually this should be slightly wider than the item views
return 180;
}
#pragma Table view delegate Methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
// cell.textLabel.text = [yourarray objectAtIndex:indexPath.row];
return cell;
}
它的工作精细输出是这样的
谢谢你。我得到了答案。你把这个(-(Void)CreateCarousel)方法称为哪里?这是基于你的要求的,例如,如果你需要在加载时显示Icarousel视图,请将代码放入viewDidLoad中。我只是将代码放在按钮操作中(屏幕截图中的转换按钮)。希望你能理解。Icarousel和table view正在以编程方式添加,不需要对此进行xib更改(用表加载icarousal)是的,很好,它工作得很好。但是当我将它与.xib文件一起使用时,它不起作用。谢谢。我得到了答案。你把这个(((Void)createIcarousel)称为哪里方法?该方法基于您的要求,例如,如果您需要在加载自身时显示Icarousel视图,请将该代码放置在viewDidLoad中。我只是将代码放在按钮操作中(屏幕截图中的转换按钮)。希望你能理解。Icarousel和table view正在以编程方式添加,不需要对此进行xib更改(用表加载icarousal)是的,很好。但当我将其与.xib文件一起使用时,它不起作用。您找到解决方案了吗?我只是按照已被接受的答案进行操作,但当我们开始触摸UITableview时,我无法向左或向右滚动。您找到解决方案了吗?我只是遵循了被接受的答案,但当我们开始触摸UITableview时,我无法向左或向右滚动。