Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.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
Ios 缩放和滚动视图_Ios_Uiscrollview - Fatal编程技术网

Ios 缩放和滚动视图

Ios 缩放和滚动视图,ios,uiscrollview,Ios,Uiscrollview,当我缩放视图时,滚动不起作用。 如何解决这个问题?谢谢 - (void)viewDidLoad { [super viewDidLoad]; NSInteger count = 10; NSInteger w = self.view.bounds.size.width; NSInteger h = self.view.bounds.size.height; UIScrollView* zoomCanvas; UIScrollView* scrollCanvas; zoomCanvas =

当我缩放视图时,滚动不起作用。 如何解决这个问题?谢谢

- (void)viewDidLoad
{
[super viewDidLoad];

NSInteger count = 10;
NSInteger w = self.view.bounds.size.width;
NSInteger h = self.view.bounds.size.height;

UIScrollView* zoomCanvas;
UIScrollView* scrollCanvas;

zoomCanvas = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, w, h)];
[zoomCanvas setMinimumZoomScale:1.0];
[zoomCanvas setMaximumZoomScale:2.0];
[zoomCanvas setDelegate:self];

scrollCanvas = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, w, h)];
[scrollCanvas setContentSize:CGSizeMake(w, h*count)];

srand(time(NULL));
for (int i=0; i<count; i++) {
    UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, h*i, w, h)];
    view.backgroundColor = [UIColor colorWithRed:rand() % 255 / 255.0 green:rand() % 255 / 255.0 blue:rand() % 255 / 255.0 alpha:1.0];
    [scrollCanvas addSubview:view];
}

[zoomCanvas addSubview:scrollCanvas];
[self.view addSubview:zoomCanvas];
}

- (UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    return [[scrollView subviews] objectAtIndex:0];
}
-(void)viewDidLoad
{
[超级视图下载];
NSInteger计数=10;
NSInteger w=self.view.bounds.size.width;
NSInteger h=self.view.bounds.size.height;
UIScrollView*zoomCanvas;
UIScrollView*滚动画布;
zoomCanvas=[[UIScrollView alloc]initWithFrame:CGRectMake(0,0,w,h)];
[zoomCanvas setMinimumZoomScale:1.0];
[zoomCanvas setMaximumZoomScale:2.0];
[zoomCanvas setDelegate:self];
scrollCanvas=[[UIScrollView alloc]initWithFrame:CGRectMake(0,0,w,h)];
[scrollCanvas setContentSize:CGSizeMake(w,h*count)];
srand(时间(空));

对于(int i=0;i如果您谈论的是在缩放画布中滚动,可能是因为您没有设置其内容大小。

-(void)viewDidLoad
- (void)viewDidLoad 
{ 
[super viewDidLoad]; 
// Do any additional setup after loading the view, typically from a nib. 

NSInteger count = 10; 
NSInteger w = self.view.bounds.size.width; 
NSInteger h = self.view.bounds.size.height; 

zoomCanvas = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, w, h)]; 
[zoomCanvas setMinimumZoomScale:1.0]; 
[zoomCanvas setMaximumZoomScale:2.0]; 
[zoomCanvas setDelegate:self]; 
[zoomCanvas setContentSize:CGSizeMake(w, h*count)]; 

dummyCanvas = [[UIView alloc] initWithFrame:CGRectMake(0, 0 , w, h*count)]; 

srand(time(NULL)); 
for (int i=0; i<count; i++) { 
    UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, h*i, w, h)]; 
    view.backgroundColor = [UIColor colorWithRed:rand() % 255 / 255.0 green:rand() % 255 / 255.0 blue:rand() % 255 / 255.0 alpha:1.0]; 
    [dummyCanvas addSubview:view]; 
} 

[zoomCanvas addSubview:dummyCanvas]; 
[self.view addSubview:zoomCanvas]; 
} 

- (UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView 
{ 
return dummyCanvas; 
}
{ [超级视图下载]; //加载视图后,通常从nib执行任何其他设置。 NSInteger计数=10; NSInteger w=self.view.bounds.size.width; NSInteger h=self.view.bounds.size.height; zoomCanvas=[[UIScrollView alloc]initWithFrame:CGRectMake(0,0,w,h)]; [zoomCanvas setMinimumZoomScale:1.0]; [zoomCanvas setMaximumZoomScale:2.0]; [zoomCanvas setDelegate:self]; [zoomCanvas setContentSize:CGSizeMake(w,h*count)]; dummyCanvas=[[UIView alloc]initWithFrame:CGRectMake(0,0,w,h*count)]; srand(时间(空));
对于(int i=0;是否在缩放画布中不发生滚动?