Search code examples
objective-cios6uiscrollviewxcode4.5

I want the presentview and its contents to be on scroll view when orientation occurs to landscape mode


when i shift from portrait mode to landscape mode the view should expand widely but the length should be the same and in scrollview so that when i scroll the fullcontents should be displayed:

if (([[UIDevice currentDevice]orientation] == UIInterfaceOrientationLandscapeLeft) ||
    ([[UIDevice currentDevice]orientation] == UIInterfaceOrientationLandscapeRight))
{
    UIScrollView *scrollView=[[UIScrollView alloc] init];
    UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 480, 480)];
    view1 = self.view;
    [scrollView addSubview:view1];
    scrollView.frame = CGRectMake(0, 0, 480, 480);
    scrollView.contentSize = CGSizeMake(480, 480);
    scrollView.delegate = self;
    scrollView.alwaysBounceVertical = YES;
    [self.view addSubview:scrollView];
}

Solution

  • if(([[UIDevice currentDevice]orientation] == UIInterfaceOrientationLandscapeLeft) || ([[UIDevice currentDevice]orientation] == UIInterfaceOrientationLandscapeRight)) { 
    UIScrollView * scrollView=[[UIScrollView alloc] init]; UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 480, 480)]; 
    view1 = self.view; [scrollView addSubview:view1]; scrollView.frame = CGRectMake(0, 0, 480, 480);           
    scrollView.contentSize = CGSizeMake(480, 480); scrollView.delegate = self; 
    scrollView.alwaysBounceVertical = YES; [self.view addSubview:scrollView]; 
    }