Tib*_*abo 10 xcode cocoa-touch interface-builder
我有一个scrollview,它必须显示一个大于可用显示区域的视图.我想轻松设计用户界面,而不必在每次必须进行一些更改时上下移动嵌入式视图.问题是可见区域外的所有内容在IB中都是不可见的.
是否有任何开关或技巧使IB中的所有内容都可见?
rob*_*off 27
我在这里发布了另一个解决方案,我觉得它更简单,更好,并且可以在故事板中使用.
使用适当的超视图,位置和大小在笔尖中创建滚动视图.
接下来,通过拖出调色板并将其放入任何现有视图之外的工作区,创建一个完全独立的顶级 UIView实例UIView.在"属性"检查器中,将"大小"弹出窗口设置为"无",并确保"状态栏","顶栏"和"底栏"都设置为"无".这是一个例子:
这个新的顶级视图将是您的内容视图.给你的视图控制器两个出口:scrollView和contentView:
@interface MyViewController
@property (nonatomic, weak) IBOutlet UIScrollView *scrollView;
@property (nonatomic, strong) IBOutlet UIView *contentView;
@end
Run Code Online (Sandbox Code Playgroud)
在笔尖中,将scrollView插座连接到滚动视图,然后将contentView插座连接到内容视图.
在内容视图中构建内容视图层次结构.根据需要设置其大小 - 它可以大于320x480(只要您将其所有条形设置为无).
在视图控制器中viewDidLoad,添加contentView为子视图scrollView并设置scrollView.contentSize为以下大小contentView:
@implementation MyViewController
@synthesize scrollView = _scrollView;
@synthesize contentView = _contentView;
- (void)viewDidLoad {
[super viewDidLoad];
[self configureScrollView];
}
- (void)configureScrollView {
CGSize size = self.contentView.bounds.size;
self.contentView.frame = CGRectMake(0, 0, size.width, size.height);
[self.scrollView addSubview:self.contentView];
self.scrollView.contentSize = size;
// If you don't use self.contentView anywhere else, clear it here.
self.contentView = nil;
// If you use it elsewhere, clear it in `dealloc` and `viewDidUnload`.
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8535 次 |
| 最近记录: |