Iphone 在uiscroll视图中移动到请求的页面
我的滚动视图中有4个页面和4个按钮。如果用户按下第一个按钮,我想跳转到第1页,依此类推,剩下的三个按钮。我不知道怎么做Iphone 在uiscroll视图中移动到请求的页面,iphone,objective-c,cocoa-touch,Iphone,Objective C,Cocoa Touch,我的滚动视图中有4个页面和4个按钮。如果用户按下第一个按钮,我想跳转到第1页,依此类推,剩下的三个按钮。我不知道怎么做 myview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)]; [self.view addSubview:myview]; scroll1 = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,
myview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
[self.view addSubview:myview];
scroll1 = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scroll1.pagingEnabled = NO;
NSInteger numberOfViews1 = 8;
float h = 0;
for (int i = 0; i < numberOfViews1; i++) {
CGFloat xOrigin = i * self.view.frame.size.height;
printf("%f\n",xOrigin);
scrollview1 = [[UIView alloc] initWithFrame:CGRectMake(0,xOrigin, self.view.frame.size.width, self.view.frame.size.height)];
scrollview1.backgroundColor = [UIColor colorWithRed:1-h green:1 blue:1 alpha:1];
[scroll1 addSubview:scrollview1];
[scrollview1 release];
h = h + 0.2f;
}
scroll1.contentSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height * numberOfViews1);
[self.view addSubview:scroll1];
myview=[[UIView alloc]initWithFrame:CGRectMake(0,0320480)];
[self.view addSubview:myview];
scroll1=[[UIScrollView alloc]initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height)];
scroll1.PaginEnabled=否;
NSInteger numberOfViews1=8;
浮点数h=0;
对于(int i=0;i
使用scrollRectToVisible:animated:如果您知道scrollview中每个页面开始的y坐标