我想在图像视图上放置自定义按钮,但这样做会使按钮消失。我在Interface Builder中做了所有这些。有没有什么窍门可以在图片视图上方看到按钮?如何在图像视图上放置自定义按钮>
1
A
回答
1
创建ImageView的编程和设置帧。之后,也编程方式创建uibutton,并将该按钮放在imageview的子视图中。确保使您的imageview属性Userinteraction Enabled为TRUE。
例如,
UIImageView *img1 = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"screen.png"]];
img1.frame = CGRectMake(50, 70, 100, 50);
[img1 setUserInteractionEnabled:TRUE];
[self.view addSubview:img1];
UIButton *btn1 = [[UIButton alloc]initWithFrame:CGRectMake(10, 10, 80, 50)];
btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
[btn1 addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchUpInside];
[btn1 setTitle:@"Show View" forState:UIControlStateNormal];
[img1 addSubview:btn1];
1
我不太了解Interface Builder。如果你试图以编程方式添加这些,意味着它会起作用。
对于编程
IBOutlet UIImageView *image;
UIImage *image1=[UIImage imageNamed:@name.jpg"];
image=[[UIImageview alloc]initWithImage:image1];
image.frame=CGRectMake(0,0,320,400);
[self.view addSubview:image];
[image release];
添加图像对于在界面生成器编程添加按钮
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(aMethod:)
forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Show View" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[self.view addSubview:button];
1
相关问题
- 1. 如何在我的自定义视图中放置按钮?
- 2. 如何在图像上放置按钮
- 3. 如何在图像上放置按钮
- 4. 自定义视图按钮
- 5. 自定义图像按钮
- 6. 图像不设置自定义按钮
- 7. 自定义视图上的AirPlay按钮
- 8. 如何在ActiveAdmin显示视图上添加自定义按钮?
- 9. 如何在android中的自定义视图上添加按钮?
- 10. 如何在自定义列表上放置图像
- 11. 在自定义图像视图中缩放图像
- 12. 如何创建像自定义列表视图的自定义图像视图?
- 13. monodroid如何在图像上放置图像并放置图像
- 14. iCarousel:如何在自定义UI视图中垂直放置图像
- 15. 在图像背景上放置图像按钮
- 16. 如何在图像上放置图像?
- 17. 如何在视频图像中定位css sprite播放按钮
- 18. 匹配缩放图像视图按钮
- 19. 如何在选中单选按钮时在图像上放置图像?
- 20. Drupal:节点上的自定义“动作”按钮在视图上
- 21. 自定义后退按钮视图
- 22. 如何在图像上放置透明按钮?
- 23. 如何在Titanium中的按钮上放置图像和标签?
- 24. UIButtonTypeInfoLight按钮的自定义图像
- 25. 自定义按钮与多个图像
- 26. Android自定义图像开/关按钮
- 27. 带图像的自定义按钮
- 28. 黑莓自定义图像按钮
- 29. 单选按钮与自定义图像
- 30. 后退按钮自定义图像
我可以知道为什么要添加图片视图上方的按钮吗? – Aravindhan 2011-04-26 05:41:48
它的喜欢dis ...我有四个标签栏..我的最后一个标签有一个imageview覆盖整个屏幕,我想放置在图像视图上方的4个按钮....但在图像视图上方添加按钮使得按钮不可见...是否可能 – kingston 2011-04-26 05:54:38