Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在uiscroll视图中移动到请求的页面_Iphone_Objective C_Cocoa Touch - Fatal编程技术网

Iphone 在uiscroll视图中移动到请求的页面

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,

我的滚动视图中有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, 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坐标