Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Uiview 为什么我的UIScrollView没有出现?_Uiview_Uiscrollview_Storyboard_Subclass - Fatal编程技术网

Uiview 为什么我的UIScrollView没有出现?

Uiview 为什么我的UIScrollView没有出现?,uiview,uiscrollview,storyboard,subclass,Uiview,Uiscrollview,Storyboard,Subclass,我正在尝试对一个包含UIScrollView的UIView进行子类化。这是我正在使用的代码: UIViewSubclass.h @property (nonatomic, retain) UIScrollView *scroll; UIViewSubclass.m @synthesize itemScrollView; - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) {

我正在尝试对一个包含UIScrollView的UIView进行子类化。这是我正在使用的代码:

UIViewSubclass.h

 @property (nonatomic, retain) UIScrollView *scroll;
UIViewSubclass.m

 @synthesize itemScrollView;

- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {

    [self setUpScrollViewWithIdentifier:@"id"];
}
return self;
}

-(void)setUpScrollViewWithIdentifier:(NSString*)scrollViewID {

NSLog(@"Setting up Scroll View with the id of: %@",scrollViewID); //This is working

scroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 90)];

//Subview of the scroll view
UIView *test = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 50, 50)];
test.backgroundColor = [UIColor blueColor];
[scroll addSubview:test];

[self addSubview:scroll]; // Adds the scrollview to the UIView
 NSLog(@"Subviews: %@",self.subviews);
}
ViewController.h

  #import "UIViewSubclass.h"

  IBOutlet UIViewSubclass *menuView;
视图控制器.m

- (void)viewDidLoad
 {
menuView = [[UIViewSubclass alloc]init];
[super viewDidLoad];
// Do any additional setup after loading the view.
}
我还在故事板中链接了视图,并将视图的类设置为UIViewSubclass,但由于某些原因,滚动视图不会出现。但当我查看此NSLog时:

 NSLog(@"Subviews: %@",self.subviews);
它在调试器中为我提供了以下信息:

Subviews: (
"<UIScrollView: 0x1d5a20e0; frame = (0 0; 320 90); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x1d5a2420>; layer = <CALayer: 0x1d5a1c60>; contentOffset: {0, 0}>"
 )
子视图:(
""
)
那么我做错了什么

scroll.contentSize = fooSize;
可能是你错过了什么