2013-05-06 43 views
0

也许是一个巨大的noob问题,但我似乎无法弄清楚,即使经过一段时间谷歌搜索我无法找到安排滚动浏览underneeth导航栏。排列UIscrollView返回

我的代码:

- (void)loadView { 

    UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; 
    scroll.backgroundColor = [UIColor blackColor]; 
    scroll.delegate = self; 
    image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Plattegrond DeFabrique schematisch.png"]]; 
    scroll.contentSize = image.frame.size; 
    [scroll addSubview:image]; 

    scroll.minimumZoomScale = scroll.frame.size.width/image.frame.size.width; 
    scroll.maximumZoomScale = 2.0; 
    [scroll setZoomScale:scroll.minimumZoomScale]; 

    self.view = scroll; 

} 

enter image description here

enter image description here

回答

0

请尝试将上海华背后的视图或尝试sendSubviewToBack。

[[self.view superview] insertSubview:scroll belowSubview:self.view]; 

[self.view sendSubviewToBack:scroll]; 

这听起来像你只是想滚动视图添加到self.view虽然。像其他答案一样,从self.view框架创建scrollView并将其添加到self.view中。

UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:self.view.frame]; // Thilina 
[self.view addSubview:scroll]; 
+0

这将导致无限递归,因为获得'self.view'调用'loadView'。 – 2013-05-06 15:48:15

+0

那么没有工作:我这样做: self.view = scroll; [self.view sendSubviewToBack:scroll]; – 2013-05-06 15:52:17

+0

你为什么设置self.view = scroll?只需将子视图添加到self.view,滚动视图就会出现在navBar下面。 – 2013-05-06 15:52:29

0

创建ScrollView时,您可以简单地使用self.view的框架。这将解决您的问题。

- (void)loadView { 

    UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:self.view.frame]; 
    scroll.backgroundColor = [UIColor blackColor]; 
    scroll.delegate = self; 
    image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Plattegrond DeFabrique schematisch.png"]]; 
    scroll.contentSize = image.frame.size; 
    [scroll addSubview:image]; 

    scroll.minimumZoomScale = scroll.frame.size.width/image.frame.size.width; 
    scroll.maximumZoomScale = 2.0; 
    [scroll setZoomScale:scroll.minimumZoomScale]; 

    [self.view addSubView:scroll]; //MarkM 

} 
+0

感谢您的帮助,奇怪的是我得到这个:http://andrewho.nl/wp-content/uploads/2013/05/iOS-simulatorschermafbeelding-6-mei-2013-23.54.49.png – 2013-05-06 22:02:44

0

由于要传递的[UIScreen mainScreen]帧在分配的UIScrollView的时间,的UIScrollView的尺寸被重叠UINavigation。与

UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:self.view.frame]; 

也而不是与滚动视图代替self.view取代它,尝试将滚动视图添加为子视图上self.view

[self.view addSubview:scrollView]; 

执行以下任务在viewDidLoad

希望它能帮助你。

+0

感谢您的帮助,目前,我只看到一半的导航栏...真的很奇怪 – 2013-05-06 21:42:44