gpt4 book ai didi

ios - 如何在 ScrollView 中获取当前图像标签?

转载 作者:行者123 更新时间:2023-11-28 19:33:33 24 4
gpt4 key购买 nike

//add the scrollview to the view
Friend_Request_Scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2-60,70,120,140)];
[Friend_Request_Scroll setAlwaysBounceVertical:NO];
Friend_Request_Scroll.delegate=self;
Friend_Request_Scroll.pagingEnabled=YES;
[Friend_Request_Scroll setShowsHorizontalScrollIndicator:NO];
[Friend_Request_Scroll setShowsVerticalScrollIndicator:NO];
CGFloat xOrigin = 0;

for (int i = 0; i <[imageCollection count]; i++) {

Back_Request_Scroll=[[UIView alloc]init];
Back_Request_Scroll.frame=CGRectMake(xOrigin,Friend_Request_Scroll.frame.origin.y-135,120,140);
Back_Request_Scroll.backgroundColor=[UIColor colorWithRed:244.0f/255.0f green:244.0f/255.0f blue:244.0f/255.0f alpha:0.5];
Back_Request_Scroll.clipsToBounds=YES;
[Friend_Request_Scroll addSubview:Back_Request_Scroll];

image = [[UIImageView alloc] initWithFrame:
CGRectMake(0, 0,
Back_Request_Scroll.frame.size.width,
Back_Request_Scroll.frame.size.height)];
[image sd_setImageWithURL:[imageCollection objectAtIndex:i] placeholderImage:[UIImage imageNamed:@""]];

image.tag=i;
[Back_Request_Scroll addSubview:image];
xOrigin= xOrigin+120;
image.userInteractionEnabled=YES;

}
Friend_Request_Scroll.contentSize = CGSizeMake(xOrigin,
0);
[self.view addSubview:Friend_Request_Scroll];


swipeleft=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeleft:)];
swipeleft.direction=UISwipeGestureRecognizerDirectionLeft;
[image addGestureRecognizer:swipeleft];


swiperight=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swiperight:)];
swiperight.direction=UISwipeGestureRecognizerDirectionRight;
[image addGestureRecognizer:swiperight];


pageControl = [[UIPageControl alloc] init];
pageControl.frame = CGRectMake(self.view.frame.size.width/2-60,Friend_Request_Scroll.frame.size.height+Friend_Request_Scroll.frame.origin.y,image.frame.size.width,20);
pageControl.numberOfPages = [imageCollection count];
pageControl.currentPage = currentValue;
[pageControl addTarget:self action:@selector(changePage) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:pageControl];

最佳答案

试试这个委托(delegate)方法。这个委托(delegate)会告诉你滚动已经完成。

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView

关于ios - 如何在 ScrollView 中获取当前图像标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41437923/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com