gpt4 book ai didi

iphone - iOS:[imagePickerController.cameraOverlayView addSubview:] 不工作

转载 作者:行者123 更新时间:2023-12-01 16:54:27 26 4
gpt4 key购买 nike

我正在尝试将 UIToolbar 添加到我的 cameraOverlayView 以获取自定义 imagePickerController。这是我要使用的代码:

[self.imagePickerController.cameraOverlayView addSubview:self.topToolbar];

尝试添加 UIToolbar 时,没有显示任何内容。如果我使用,将其封装到 UIView 并将其设置为 view 属性有效:
[self.imagePickerController.cameraOverlayView addSubview:self.view];

但这限制了我在想要添加多个 View 时为我的叠加层使用一个 View 。我知道我可以将所有内容封装到一个大 View 中,但是当我这样做时,我的底部工具栏无法正确显示。

有没有人成功地将 UIToolbar 作为 subview 添加到 cameraOverlayView?

最佳答案

我认为你需要一个 View 来把你需要的所有东西放在你的 cameraOverlay 中。
例如:

TempView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
TempView.alpha = 1.0;

anImageView1 = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@""]];
anImageView1.frame = CGRectMake(0, 0, anImageView1.image.size.width, anImageView1.image.size.height-50);
anImageView1.hidden = NO;
anImageView1.alpha = 1.0f;

tabBarHolder = [[UIImageView alloc]init];
tabBarHolder.backgroundColor = [UIColor blackColor];
tabBarHolder.frame = CGRectMake(0, 415, 320, 80);

tampBtn = [[UIButton alloc] initWithFrame:CGRectMake(15, 430, 35, 35)];
[tampBtn setBackgroundImage:[UIImage imageNamed:@"iconBack.png"] forState:UIControlStateNormal];
[tampBtn addTarget:self
action:@selector(xup)
forControlEvents:UIControlEventTouchUpInside];

ctampBtn = [[UIButton alloc] initWithFrame:CGRectMake(145, 430, 35, 35)];
[ctampBtn setBackgroundImage:[UIImage imageNamed:@"iconCamera.png"] forState:UIControlStateNormal];
[ctampBtn addTarget:self
action:@selector(takephoto)
forControlEvents:UIControlEventTouchUpInside];

[TempView addSubview:ctampBtn];
[TempView addSubview:tampBtn];
[TempView addSubview:anImageView1];
[TempView addSubview:tabBarHolder];
[TempView bringSubviewToFront:tabBarHolder];
[TempView bringSubviewToFront: ctampBtn];
[TempView bringSubviewToFront:tampBtn];

imagePicker.cameraOverlayView =TempView;

关于iphone - iOS:[imagePickerController.cameraOverlayView addSubview:] 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13021261/

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