2014-01-16 61 views
0

我有一個UIScrollView(類似於在App Store上顯示的特色項目),它有3個視圖,其中加載了xibs。一切都可以找到,除非我可以獲得我在xib上啓動的UIButton。我想我錯過了一些顯而易見的東西,就是看不到它。我在這裏和其他地方嘗試了各種答案,無濟於事。在UISclickView UIScrollView上的UIButton

預先感謝

從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 

屏幕截圖 Showing view controller w/ scrollview

Showing view which is loaded into scrollview

+1

並ü分配任何出口採取行動,將acutal視圖 – CoolMonster

+0

設置視圖的幀大小是的,我有在屬於意見IBActions加載到滾動視圖中。目前不工作。 – nicktones

+0

你的視圖代碼如何?它上面沒有提供試圖發佈代碼中涉及的代碼。 – CoolMonster

回答

0

該固定通過之前將其加入到所述滾動視圖