2012-10-31 93 views
0

我有一個UIScrollView,當我運行我的應用程序時滾動視圖工作正常。當我將兩個按鈕添加到滾動視圖時,在底部和頂部的另一個按鈕上,滾動功能將消失。我還沒有對按鈕調用任何操作。我只想在行動中看到滾動視圖添加項目時UIScroll視圖不會滾動

不知道爲什麼會發生這種情況。

這是我的代碼。

.H

@interface ViewController : UIViewController { 
IBOutlet UIScrollView *theScroller; 
} 

@end 

.M

@implementation ViewController 

- (void)viewDidLoad 
{ 
[theScroller setScrollEnabled:YES]; 
[theScroller setContentSize:CGSizeMake(320, 900)]; 
[super viewDidLoad]; 
// Do any additional setup after loading the view, typically from a nib. 
} 

- (void)didReceiveMemoryWarning 
{ 
[super didReceiveMemoryWarning]; 
// Dispose of any resources that can be recreated. 
} 

@end 

回答

0

變化如下修改:

.H

@interface ViewController : UIViewController 
{ 


    IBOutlet UIScrollView *theScroller; 

} 


@property(nonatomic,retain)IBOutlet UIScrollView *theScroller; // Add this Line 

**#import "ViewController.h" 
@interface ViewController() 
@end 
@implementation ViewController 
@synthesize theScroller; // Add this Line 

- (void)viewDidLoad 

{ 
    [super viewDidLoad]; 


    [theScroller setScrollEnabled:YES]; 
    [theScroller setContentSize:CGSizeMake(320, 900)]; 
    [super viewDidLoad]; 

} 

在你的XIB;

  1. 組代表和鏈接正確

enter image description here

相關問題