我正在尝试将相机显示在滚动视图上,就像他们使用滑动导航一样。我试着像下面那样设置它,我创建一个要显示的对象数组,其中相机就是其中之一,然后将其设置为我的滚动条的子视图。此代码无错误,但屏幕上不显示任何内容。任何人都可以帮我看看我可能做错了什么。我认为可能是添加了子视图。我应该使用页面视图吗?有没有人试图制作类似于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;
}
答案 0 :(得分:1)