简体   繁体   English

使用Interface Builder在屏幕外创建UIButton

[英]Create UIButton offscreen with Interface Builder


I want to create a big UIScrollView , its contentView should contain more than 30 UIButton . 我想创建一个大的UIScrollView ,它的contentView应该包含30个以上的UIButton Positions of these UIButton are not rectiligne and cannot be create 'programmaticaly' so I've placed all these UIButton on a UIView manually. 这些UIButton位置不是可调节的,不能以“编程方式”创建,因此我将所有这些UIButton手动放置在UIView I zoom/dezoom and scroll all over my UIScrollView fine BUT here is my problem : 我缩放/缩放并在UIScrollView滚动, 这里是我的问题:
UIButton created offscreen is not accessible, I mean I can't click them (only UIButton created in the CGRect(0.f, 0.f, 320.f, 480.f) can be click. 无法在屏幕外创建的UIButton ,我的意思是无法单击它们(只能单击在CGRect(0.f, 0.f, 320.f, 480.f)创建的UIButton
Any suggestion ? 有什么建议吗?

Create a view, put a scrollView inside that view, and place your buttons on the scrollView. 创建一个视图,将一个scrollView放在该视图中,然后将按钮放在scrollView上。 While adding buttons and moving them around, be certain that they're always inside the scrollView by looking at the object hierarchy in interface builder. 在添加按钮并四处移动时,通过查看界面构建器中的对象层次结构,确保它们始终在scrollView内。

You can slide the scrollView around as you place things, no need to zoom. 您可以在放置事物时在周围滚动scrollView,而无需缩放。 As long as your buttons are children of your scrollView it should work fine. 只要您的按钮是scrollView的子级,它就可以正常工作。

视图中的scrollView中的按钮

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从代码而不是接口生成器创建UIButton? - How to create a UIButton from code instead of Interface builder? 以编程方式启用/禁用Interface Builder uibutton - Enable/Disable Interface Builder uibutton programmatically 接口生成器中UIButton的“播放声音”属性 - “Plays Sound” Property of UIButton in Interface Builder 通过代码设置在Interface Builder中创建的UIButton的图像 - Set Image of UIButton Created in Interface Builder, by code 在Interface Builder中创建UICollectionViewCell - Create UICollectionViewCell in Interface Builder 在不使用cocoa中的接口构建器的情况下调用uibutton的动作方法 - call action method for a uibutton without using interface builder in cocoa 界面构建器UIButton自定义背景图像无法在模拟器/设备上运行 - Interface builder UIButton custom background image not working on simulator/device 在Interface Builder(XCode 4)中设置UIButton拉伸背景图像 - Setting UIButton stretched background images in Interface Builder (XCode 4) 在界面构建器中插入UIButton来控制我的应用程序的流程 - Inserting UIButton in interface builder to control the flow of my app 如何重置界面生成器中提到的UIButton背景图像? - how to reset UIButton background image mentioned in interface builder?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM