0

I'm using Paged UIScrollView with an embedded UIPageControl like explained at https://github.com/romaonthego/REPagedScrollView.

The code works fine when I use

UIView *page1 = [[UIView alloc] initWithFrame:CGRectMake(20, 20, 280, self.view.frame.size.height - 40)];
page1.backgroundColor = [UIColor lightGrayColor];
[scrollView addPage:page1];

But I need to use a nib file for my project. I'm calling it like :

UIView *page1 = [[[NSBundle mainBundle] loadNibNamed:@"mySubViewController" owner:self options:nil] objectAtIndex: 0];
page1 = [[UIView alloc] initWithFrame:CGRectMake(20, 20, 280, self.view.frame.size.height - 40)];
page1.backgroundColor = [UIColor lightGrayColor];
[scrollView addPage:page1];

Which almost works fine, I can call the view, only problem is that the view does not listen to initWithFrame:CGRectMake, it loads full screen and I can not see the page control anymore to navigate.

Autolayout is set to off.

Could anyone point me where I am wrong here ? What I could do to solve this issue ?

Best regards, David

David
  • 213
  • 3
  • 10
  • As a side note: Ditch this outdated class and use a [`UIPageViewController`](https://developer.apple.com/library//ios/documentation/UIKit/Reference/UIPageViewControllerClassReferenceClassRef/index.html). – Matthias Bauch Mar 13 '15 at 15:14
  • I'd like to, but I'm quite a newbie in iOS, and this is the nearest source I found for what I'm trying to achieve. – David Mar 13 '15 at 15:16
  • Hi Matthias, thanks a lot for that side note !!! Feeling kind of stupid, I turned my work around and did what I had to do in a few minutes while I was stuck with it for 2 days. UIPageViewController is great !!! if anyone needs it, this tutorial helped me a lot (http://www.appcoda.com/uipageviewcontroller-tutorial-intro/) ! – David Mar 13 '15 at 15:43
  • The only thing I prefered in REPagedScrollView is that I had an identifier for each view (page1). – David Mar 13 '15 at 15:50

1 Answers1

0

You can set frame of any view manually with method -(void)setFrame:(CGRect)frame

    UIView *page1 = [[[NSBundle mainBundle] loadNibNamed:@"mySubViewController" owner:self options:nil] objectAtIndex: 0];
    page1.backgroundColor = [UIColor lightGrayColor];
    page1.frame = CGRectMake(20, 20, 280, self.view.frame.size.height - 40);
    [scrollView addPage:page1];
Pavel Gatilov
  • 2,570
  • 2
  • 18
  • 31
  • I tried it but it does not seem to work, could it be because the code is writtent inside - (void)viewDidLoad ? – David Mar 13 '15 at 15:15