سؤال

I am new to iOS programming.I find the tutorial for displaying the image view as cover flow as shown in link http://code4app.net/ios/iCarousel-for-Cover-Flow/4f87d2db06f6e79d32000000

but my requirement is to display the list of tableviews as cover flow. Please help me.

هل كانت مفيدة؟

المحلول

Here i have used iCarousel view. After integrating the SDK(import iCarousel.h & iCarousel.m) into your application. Create ICarousel view and integrated table view in all the icarousel sub views. Here is my code

In .h file

iCarousel *categorySubView;

In .M file.

-(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;

    }

Its working fine Output is like this...

enter image description here

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top