views:

55

answers:

1

hello all.Am facing a probem with my scrollview.Am displaying the image in a scrollview programatically and i added the zooming and paning effects.When i run the application image is displaying in the scroll view but it is not in centre(like it is displaying at right corner and some part of image is inside the scrollview)After zooming when i scroll the image the image is moving and i can see the black area which i dont want. Please,somebody can help me Thanks in advance here is the code

  mainView2 = [[UIScrollView alloc]init];

 [mainView2 setFrame:CGRectMake(imageView2.frame.origin.x, imageView2.frame.origin.y, 222, 120)];
  [mainView2 setContentSize:CGSizeMake(600,600)];

  [mainView2 setMaximumZoomScale:2.0];

  [mainView2 addSubview:imageView2];
  mainView2.delegate = self;
  [self.view addSubview:mainView2];
  mainView2.scrollsToTop = NO;

here mainview2 is my scrollview and imageview2 is the uiimageview which i want to display in scrollview

A: 

I don't know exactly what you mean "I can see the black Area". However, the "center image" problem is quite a common one. As far as I know, there is no out of the box way to solve this. Fortunately, there is some great code on github which handels image scrolling in a UIScrollView nicely. See this question and this github project for further information.

Phlibbo