开发者

How to navigate from one view to other view using UIPageControl?

开发者 https://www.devze.com 2022-12-22 08:48 出处:网络
I have page control butnot navigating to other view. so please provide the solution. pageControl=[[UIPageControl alloc] initWithFrame:CGRectMake(0,380,320,40)];

I have page control but not navigating to other view. so please provide the solution.

    pageControl=[[UIPageControl alloc] initWithFrame:CGRectMake(0,380,320,40)];
    pageControl.backgroundColor=[UIColor clearColor];
    pageControl.user开发者_开发技巧InteractionEnabled =YES;
    [pageControl addTarget:self action:@selector(pageAction:) forControlEvents:UIControlEventValueChanged];

    [pageControl setHighlighted:YES];


-(void)pageAction:(UIPageControl*)control
{       
    [self displayNextPage];
    [self displayPreviousPage];
}

Thank You, Madan Mohan.


Hope this helps:

-(void)pageAction:(UIPageControl*)control
{       
int page = pageControl.currentPage;
CGRect frame = pagingScrollView.frame;
frame.origin.x = (myScrollView.frame.size.width * page);
[myScrollView scrollRectToVisible:frame animated:YES];
}


Swift :

       func changeImageOnPageControl(sender: UIPageControl) {
            let page = sender.currentPage;
            var frame = self.scrollViewBase.frame;
            frame.origin.x = self.scrollViewBase.frame.size.width * CGFloat(page);
            self.scrollViewBase.scrollRectToVisible(frame, animated: true);

        }
0

精彩评论

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