2011-05-10 80 views
0

我想在ScrollView Box中顯示5個按鈕,但不幸的是我寫的代碼對我的UIButtons沒有任何影響(我無法向上或向下滾動,您能告訴我爲什麼嗎?)將UIButtons添加到ScrollView中

感謝您的幫助,我花了很多的時間就可以了(新秀),但我仍然無法找到解決辦法......

我的代碼:

FirstViewController.h:

#import <UIKit/UIKit.h> 


@interface FirstViewController : UIViewController <UIScrollViewDelegate> { 
IBOutlet UIScrollView *scroll; 
UIButton *button; 
UIButton *button2; 
UIButton *button3; 
} 

@property (nonatomic, retain) IBOutlet UIButton *button; 
@property (nonatomic, retain) IBOutlet UIButton *button2; 
@property (nonatomic, retain) IBOutlet UIButton *button3; 
@property(nonatomic,retain) IBOutlet UIScrollView *scroll; 

@end 

FirstViewController.m:

#import "FirstViewController.h" 

@implementation FirstViewController 
@synthesize button; 
@synthesize button2; 
@synthesize button3; 
@synthesize scroll; 


- (IBAction)goToViewTwo { 
     } 

- (void)viewDidload { 
    [super viewDidLoad]; 
    [scroll setScrollEnabled:YES]; 
    [scroll setContentSize:CGSizeMake (500, 1000)]; 
} 

- (void)dealloc { 
    [super dealloc]; 
    [button release]; 
    [scroll release]; 
}          
@end 

層次在FirstView.xib:

View 
    Action Sheet 
    Text View 
    ScrollView 
    Button 
    Button 
    Button 

關於奧特萊斯:

  • 滾動視圖鏈接到文件的所有者與 「滾動」
  • 視圖鏈接到文件的所有者作爲一個「查看」

回答

0

我想你在Interface Builder中實現滾動,並且該應用程序是爲iPad(對於contentSize)。看看你是否有相同的配置在IB和代碼中,尤其是[scroll setScrollEnabled:YES];

+0

Thx爲你的答案,我檢查了IB並且我沒有看到我的錯誤:x,你能否給我你的意見: http ://imageshack.us/photo/my-images/146/capturedcran20110510130.png/ – Nicolas 2011-05-10 17:12:11

+0

好的,XIB很好。你有沒有添加按鈕作爲滾動的子視圖或它的父母(self.view)子視圖? – 2011-05-10 17:55:29

相關問題