【发布时间】:2015-05-16 02:55:07
【问题描述】:
我正在使用带有嵌入式 UIPageControl 的 Paged UIScrollView,如 https://github.com/romaonthego/REPagedScrollView 中所述。
当我使用时代码运行良好
UIView *page1 = [[UIView alloc] initWithFrame:CGRectMake(20, 20, 280, self.view.frame.size.height - 40)];
page1.backgroundColor = [UIColor lightGrayColor];
[scrollView addPage:page1];
但我需要为我的项目使用 nib 文件。我这样称呼它:
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];
这几乎可以正常工作,我可以调用视图,唯一的问题是视图不听 initWithFrame:CGRectMake,它会加载全屏,我再也看不到要导航的页面控件。
自动布局设置为关闭。
谁能指出我错在哪里?我能做些什么来解决这个问题?
最好的问候, 大卫
【问题讨论】:
-
附带说明:抛弃这个过时的课程并使用
UIPageViewController。 -
我愿意,但我是 iOS 的新手,这是我找到的最接近的资源。
-
嗨,Matthias,非常感谢您的旁注!!!感觉有点愚蠢,我把工作转过来,在几分钟内完成了我必须做的事情,而我却坚持了 2 天。 UIPageViewController 很棒!!!如果有人需要,本教程对我帮助很大 (appcoda.com/uipageviewcontroller-tutorial-intro)!
-
在 REPagedScrollView 中我唯一喜欢的是,我为每个视图 (page1) 设置了一个标识符。
标签: ios xcode uiscrollview loadnibnamed initwithframe