2

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

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

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

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

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

有没有人成功地将 UIToolbar 作为子视图添加到 cameraOverlayView?

4

1 回答 1

0

我认为你需要一个视图来把你需要的所有东西放在你的 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;
于 2012-10-23T03:40:00.100 回答