LandscapeOrientation on start of didload method in objective c

前端 未结 3 1421
粉色の甜心
粉色の甜心 2021-01-13 23:34

I\'ve made an iPad application,

It works fine when I load my application in portrait mode for first time, but when I load my application in landscape mode for the fi

3条回答
  •  孤独总比滥情好
    2021-01-13 23:47

    I had similar issue with UIScrollView. I had it fixed by aligning the subviews as suggested here.

    - (void)alignSubViews
    {
        // Position all the content views at their respective page positions
        scrollView.contentSize = CGSizeMake(self.contentViews.count * scrollView.bounds.size.width,
                                            scrollView.bounds.size.height);
        NSUInteger i = 0;
        for (UIView *v in self.contentViews) {
            v.frame = CGRectMake(i * scrollView.bounds.size.width, 0,
                                 scrollView.bounds.size.width, scrollView.bounds.size.height);
            i++;
        }
    }
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        //Setup subviews and then align the views.
    
        [self alignSubViews];
    }
    
    - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
                                             duration:(NSTimeInterval)duration 
    {
        [self alignSubViews];
        scrollView.contentOffset = CGPointMake(self.currentPage * scrollView.bounds.size.width, 0);
    }
    

提交回复
热议问题