문제

I Have a horizontal UIScrollView. I want to do a magazine app. I create a dynamic UIview as this:

UIView *one=[[UIView alloc]initWithFrame:CGRectMake(self.view.frame.size.width*4, 0, 0, 0)];

and my view:

pageOneViewController *pageOne=[[pageOneViewController alloc]init];

and then:

[one addSubview:pageOne.view];
[self.scroll addSubview:one];

with these codes, the elements that in pageOneViewController, can not clickable.

if I add "pageOneViewController.view" directly to the self.scroll they can.

how can I make clickable with first situation?

도움이 되었습니까?

해결책

Here in your code

  UIView *one=[[UIView alloc]initWithFrame:CGRectMake(self.view.frame.size.width*4, 0, 0, 0)];

Here width and height are 0, try to set background color and non zero values for height and width for view and check your view in scrollView.

  pageOneViewController *pageOne=[[pageOneViewController alloc]init];

  // Y value as per your need, I have set 0.
  UIView *one=[[UIView alloc]initWithFrame:CGRectMake(self.view.frame.size.width*4, 0, pageOne.view.frame.size.width, pageOne.view.frame.size.height)];
  [one addSubview:pageOne.view];
  [self.scroll addSubview:one];

다른 팁

You can't add root view from view controller to other views. Use UIPageViewController for creating viewcontrollers as pages.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top