2012-10-31 65 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

相关问题