gpt4 book ai didi

ios - 界面类似于带有 UIScrollView 的 Snapchat

转载 作者:行者123 更新时间:2023-11-29 13:01:48 24 4
gpt4 key购买 nike

我正在尝试让相机显示在 ScrollView 上,就像 snapchat 的滑动导航一样。我尝试像下面那样设置它,我创建了一个要显示的对象数组,相机是其中之一,然后将其设置为我的滚动条的 subview 。此代码没有错误,但屏幕上没有显示任何内容。谁能帮我看看我可能做错了什么。我认为这可能是添加 subview 。我应该改用页面 View 吗?有没有人尝试制作类似于 snapchat 的用户界面并可以提供一些链接?谢谢

//Set Up the Camera View
[[self captureManager] addVideoInput];

[[self captureManager] addVideoPreviewLayer];
CGRect layerRect = [[[self view] layer] bounds];
[[[self captureManager] previewLayer] setBounds:layerRect];
[[[self captureManager] previewLayer] setPosition:CGPointMake(CGRectGetMidX(layerRect),
CGRectGetMidY(layerRect))];
UIView *captureView = [[UIView alloc] initWithFrame:self.view.bounds];
[[captureView layer] addSublayer:[[self captureManager] previewLayer]];

[[captureManager captureSession] startRunning];


int PageCount = 2;
NSMutableArray *arrImageName =[[NSMutableArray alloc]initWithObjects:settingsView,captureView,nil];
UIScrollView *scroller = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
scroller.scrollEnabled=YES;
scroller.backgroundColor = [UIColor clearColor];
[scroller setShowsHorizontalScrollIndicator:NO];
scroller.pagingEnabled = YES;
scroller.bounces = NO;
scroller.delegate = self;
[self.view addSubview:scroller];
int width=scroller.frame.size.width;
int xPos=0;
for (int i=0; i<PageCount; i++)
{
UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(xPos, 0, scroller.frame.size.width, scroller.frame.size.height)];
UIView *view2 = [arrImageName objectAtIndex:i];
[view1 addSubview:view2];
[scroller addSubview:view1];
scroller.contentSize = CGSizeMake(width, 0);
width +=scroller.frame.size.width;
xPos +=scroller.frame.size.width;
}

最佳答案

关于ios - 界面类似于带有 UIScrollView 的 Snapchat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19600906/

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