gpt4 book ai didi

ios - 为多个图像添加页面 Controller ?

转载 作者:行者123 更新时间:2023-11-28 17:51:11 26 4
gpt4 key购买 nike

当点击一个表格 View 单元格时,它会导航到一个新 View 以显示包含图像、描述等内容的详细信息。要在页面 Controller 中显示多个图像,可以做什么?

最佳答案

在scrollview和page Controller中添加图片

UIScrollView *image_scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, screenWidth, 200)];
int x=0;
for (int i=0; i<image_ary.count; i++)
{
UIImageView *img=[[UIImageView alloc]initWithFrame:CGRectMake(x, 0,screenWidth, height)];
[image_scrollView addSubview:img];
x=screenWidth+x;
}
[self.view addSubView image_scrollView];
UIPageControl *pageControl = [[UIPageControl alloc] init];
pageControl.frame = CGRectMake(screenWidth/4, pageControlY, 160, 30);
pageControl.numberOfPages = 5;
pageControl.currentPage = 0;
[self.view addSubview:pageControl];

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
float fractionalPage =scrollView.contentOffset.x / screenWidth;
NSInteger page = lround(fractionalPage);
pageControl.currentPage = page;
}

关于ios - 为多个图像添加页面 Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35448525/

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