jeudi 13 août 2015

UIPageControll not properly working in UITableView cell

I am implementing sliding image demo on UITableView also I am using UIPageControl for that. When I slide image on first row, page control changes properly but when I slide image of second row page control starts from where it was left at first row. Please help me...Here is my code

-(void)seePhotosBtnClicked:(UIButton *)sender
{
    photoView.hidden = NO;


    CGPoint touchPoint = [sender convertPoint:CGPointZero toView:addressTable]; // maintable --> replace your tableview name
    NSIndexPath *clickedButtonIndexPath = [addressTable indexPathForRowAtPoint:touchPoint];
    NSString *areaToSearch = [[addressInfoArray valueForKey:@"IMAGEPATH"]objectAtIndex:clickedButtonIndexPath.row];


    NSArray *urlArray = [areaToSearch componentsSeparatedByString: @","];

    for (int i = 0; i<=2; i++)
    {
        NSURL *imageURL = [NSURL URLWithString:[urlArray objectAtIndex:i]];
        NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
        UIImage *image = [UIImage imageWithData:imageData];

        CGRect frame;
        frame.origin.x =pagedScrollView.frame.size.width * i;
        frame.origin.y = 0;
        frame.size = pagedScrollView.frame.size;
        UIImageView *imgView=[[UIImageView alloc]initWithFrame:frame];

        imgView.image = image;
        [pagedScrollView addSubview:imgView];

    }
     pagedScrollView.contentSize = CGSizeMake(pagedScrollView.frame.size.width * 3, pagedScrollView.frame.size.height);
        [pageControl addTarget:self action:@selector(changePage:) forControlEvents:UIControlEventValueChanged];

   }

- (void)changePage:(id)sender
{


    // update the scroll view to the appropriate page
    CGRect frame;
    frame.origin.x = pagedScrollView.frame.size.width * pageControl.currentPage;
    frame.origin.y = 0;
    frame.size = pagedScrollView.frame.size;
    [pagedScrollView scrollRectToVisible:frame animated:YES];



}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire