我想在ScrollView Box中显示5个按钮但不幸的是我写的代码对我的UIButtons没有影响(我不能向上或向下滚动,你能告诉我为什么吗?
谢谢你的帮助,我花了很多时间(Rookie),但我还是找不到解决方案......
我的代码:
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 :(得分:0)
我想你在Interface Builder中实现了滚动,并且该应用程序适用于iPad(用于contentSize)。查看您在IB和代码中是否具有相同的配置,尤其是[scroll setScrollEnabled:YES];