开发者

Why wont my scrollView start with my coordinate?

I need to position a scrollView (with a textscroll inside) into my iPad App.

I've use this code:

- (void)showRootPopoverButtonItem:(UIBarButtonItem*)barButtonItem 
{
    movie_scroll.frame = CGRectMake(50, 430, 700, 600);
    movie_scroll.directionalLockEnabled = YES;
    movie_detail.frame = CGRectMake(0, 0, 600, 400);

    NSLog(@"You are in portrait from showRootPopoverButtonItem"); 
}

- (void)invalidateRootPopoverButtonItem:(UIBarButtonItem*)barButtonItem 
{
    movie_scroll.frame = CGRectMake(50, 540, 700, 400);
    movie_scroll.directionalLockEnabled = YES;
    movie_detail.frame = CGRectMake(0, 0, 600, 300);

    NSLog(@"You are in landscape from invalidateRootPopoverButtonItem"); 
}

And this too in - (void)viewDidLoad

//change position for scrollView
if (UIDeviceOrientationIsLandscape(self.interfaceOrientation))
{
    movie_scroll.frame = CGRectMake(50, 540, 700, 400);
    movie_scroll.directionalLockEnabled = YES;
    movie_detail.frame = CGRectMake(0, 0, 600, 300);

    NSLog(@"You are in  landscape from viewDidLoad");   
}
else 
{
    movie_scroll.frame = CGRectMake(50, 430, 700, 600);
    movie_scroll.directionalLockEnabled = YES;
    movie_detail.frame = CGRectMake(0, 0, 600, 400);

    NSLog(@"You are in portrait da viewDidLoad");   
}

Well when I run the application for the first time in portrait I don't have the scrollView in the position. If I try to rotate the device the scrollView start positio开发者_运维知识库n...

Why?


You should probably put the viewDidLoad code into viewWillAppear:, as the bounds of everything may not have been set in viewDidLoad, before viewWillAppear:. I don't understand your last question: "If I try to rotate the device the scrollView start position..."

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜