ページあたり 75x75 で単一のボタンを表示する 100x100 ピクセルのスクロール ビュー (ページング モード) を作成しようとしています。最初の画像を表示できますが、次のページに移動できません。これが私が使用しているコードです、誰かが私を助けてくれますか?
.h
@property (nonatomic , retain) IBOutlet UIScrollView *scrollMenu;
.m
@synthesize scrollMenu;
-(void)viewDidLoad {
scrollMenu.pagingEnabled = YES;
NSInteger numberOfButtons = 2;
for (int i = 0; i < numberOfButtons; i++) {
//Array of images for the buttons
NSArray *menuItems = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"1.png"], [UIImage imageNamed:@"2.png"], nil];
//Create A Button
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
//Give the button an action
[button addTarget:self action:@selector(menuItemSelected:) forControlEvents:UIControlEventTouchUpInside];
//Give the button an image
[button setImage:[menuItems objectAtIndex:i] forState:UIControlStateNormal];
//Most likely WRONG
button.frame = CGRectMake(i*(20+75), 8.0, 75, 75);
button.showsTouchWhenHighlighted=YES;
//Assign a tag
button.tag = i;
//Add the button to the view
[scrollMenu addSubview:button];
}
//Most likely WRONG
scrollMenu.contentSize = CGSizeMake(100,100);
[self.view addSubview:scrollMenu];
}
[super viewDidLoad];
}