1

我的项目是单视图应用程序并添加到带有参数的视图控制器滚动视图

[scroller setScrollEnabled:YES];
[scroller setContentSize:CGSizeMake(0, 960)];

如果屏幕分辨率为 320x480,那么我们有一些不可见的“屏幕 2”(320x480)我该怎么做 - 确实在“屏幕 2”位置加载了应用程序,之后我不能向下滚动,而是在启动应用程序时向上滚动。

例如

如何释放它?

4

2 回答 2

4

您必须根据屏幕大小为滚动视图提供适当的内容大小。

假设滚动视图是纵向全屏的:

//------------------------------------------
- (void)viewDidLoad{
  [super viewDidLoad];

  CGRect screenSize = [[UIScreen mainScreen] bounds];

  [scroller setScrollEnabled:YES];
  [scroller setContentSize:CGSizeMake(0, screenSize.size.height)];

}

//------------------------------------------

- (void)viewDidAppear:(BOOL)animated{
  [super viewDidAppear:animated];

  CGRect screenSize = [[UIScreen mainScreen] bounds];

  CGPoint scrollPoint = CGPointMake( 0.0, screenSize.size.height / 2);

  [scroller setContentOffset:scrollPoint animated:YES];

}
于 2013-01-26T11:37:30.017 回答
0
 - (void)viewDidLoad
   {
        self.YourSecondView.frame = CGRectMake("As You Need");
        [self.ScView addSubview:self.YourSecondView];

        CGRect rect = CGRectMake(self.YourSecondView.frame.origin.x,self.YourSecondView.frame.origin.y,self.YourSecondView.frame.size.width,self.YourSecondView.frame.size.height);        
        [self.ScView scrollRectToVisible:rect animated:YES];
   }
于 2013-01-26T12:16:57.110 回答