我有一个UIScrollView (类似于在App上显示有特色的条目),它有3个视图,带有xibs,加载到其中。所有的工作都找到了,除了我可以得到的UIButtons,我有在西克斯发射。我想我错过了一些明显看不见的东西。我在这里和其他地方尝试过各种各样的答案,但都没有结果。
提前感谢
包含滚动视图的viewDidLoad在ViewController上的代码
LSCWInfoView *view1 = [[[NSBundle mainBundle]
loadNibNamed:@"LSCW-InfoView"
owner:self options:nil]
firstObject];
CGRect frame;
frame.origin.x = 0;
frame.origin.y = 0;
frame.size = self.activityPageControl.frame.size;
[view1 setFrame:frame];
[self.activityScrollView addSubview:view1];
ScrambledInfoView *view2 = [[[NSBundle mainBundle]
loadNibNamed:@"Scrambled-InfoView"
owner:self options:nil]
firstObject];
CGRect frame2;
frame2.origin.x = 320;
frame2.origin.y = 0;
frame2.size = self.activityPageControl.frame.size;
[view2 setFrame:frame2];
[self.activityScrollView addSubview:view2];
TestInfoView *view3 = [[[NSBundle mainBundle]
loadNibNamed:@"Test-InfoView"
owner:self options:nil]
firstObject];
CGRect frame3;
frame3.origin.x = 640;
frame3.origin.y = 0;
frame3.size = self.activityPageControl.frame.size;
[view3 setFrame:frame3];
[self.activityScrollView addSubview:view3];
_activityScrollView.contentSize = CGSizeMake(_activityScrollView.frame.size.width * 3, _activityScrollView.frame.size.height);编辑-加载到滚动视图中的一个视图的代码(其他2个相同)
#import "LSCWInfoView.h"
@implementation LSCWInfoView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
- (IBAction)lscwPlayButtonPressed:(id)sender
{
NSLog(@"YEP");
}
@end截图


发布于 2014-01-16 15:34:07
这是通过在将视图添加到滚动视图之前设置视图的框架大小来修正的。
https://stackoverflow.com/questions/21164511
复制相似问题