如何在ios6.1中显示表视图列表作为封面流程

时间:2013-03-05 07:47:50

标签: uitableview ios6 coverflow

我是iOS编程的新手。我找到了将图像视图显示为封面流程的教程,如链接http://code4app.net/ios/iCarousel-for-Cover-Flow/4f87d2db06f6e79d32000000

所示

但我的要求是将tableviews列表显示为封面流程。请帮帮我。

1 个答案:

答案 0 :(得分:3)

这里我使用了iCarousel视图。将SDK(导入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;

    }

它的工作正常输出就像这样......

enter image description here