简体   繁体   English

当前uiview的addSubView

[英]addSubView of present uiview

I have created a custom UIView with some labels inside, in other controller. 我在其他控制器中创建了一个自定义UIView,其中带有一些标签。 I have named the UIView "ReportsView.h" 我已将UIView命名为“ ReportsView.h”

Then back to the main controller UIView, I wish to add a subview inside UIScrollView. 然后回到主控制器UIView,我希望在UIScrollView中添加一个子视图。 Using the codes below, the view is added, but the content is blank. 使用以下代码,添加了视图,但内容为空白。 It is just like adding a pure blank UIView instead of my ready ReportsView. 就像添加纯空白的UIView而不是我准备的ReportsView一样。

ReportsView *rv = [[ReportsView alloc] init];
[rv setFrame:CGRectMake(self.scrollView.frame.size.width,0,self.scrollView.frame.size.width,600)];
[self.scrollView addSubview:rv];
CGRectMake(self.scrollView.frame.size.width,0,self.scrollView.frame.size.width,600)

is being placed just off screen. 被放置在屏幕之外。 (or the scrollview is clipping subviews) (或scrollview正在剪切子视图)

I believe the origin of the scrollview's subview should be 0,0 in your case 我认为滚动视图的子视图的原点应为0,0

CGRectMake(0,0,self.scrollView.frame.size.width,600)

or 要么

CGRectMake(0,0,self.scrollView.frame.size.width,self.scrollView.frame.size.height)

should work 应该管用

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM