Objective c 程序设计的景观模式

Objective c 程序设计的景观模式,objective-c,ios7,Objective C,Ios7,我正在做一个新的项目,我需要景观和纵向视图,我已经设计了我的页面。这幅肖像画效果不错,但如何在程序中设置风景。帮帮我,伙计们 阅读。另外,如果您确实想在iOS决定使用另一个时强制进行定向,则无法使用公共API。我使用的ViewDidLayoutSubView如下: -(void)viewDidLayoutSubviews { CGRect bounds = self.view.bounds; if (bounds.size.width > bounds.size.heigh

我正在做一个新的项目,我需要景观和纵向视图,我已经设计了我的页面。这幅肖像画效果不错,但如何在程序中设置风景。帮帮我,伙计们

阅读。另外,如果您确实想在iOS决定使用另一个时强制进行定向,则无法使用公共API。

我使用的ViewDidLayoutSubView如下:

-(void)viewDidLayoutSubviews
{
    CGRect bounds = self.view.bounds;
    if (bounds.size.width > bounds.size.height)
    {
        // landscape layout
        [self.myView setFrame:CGRectMake(10.0f, 80.0f, 330.0f, 318.0f)];
    }
    else
    {
        // portrait layout
        [[self.myView setFrame:CGRectMake(10.0f, 10.0f, 1500.0f, 318.0f)];
    }
}
这对我来说很好。我假设你的应用程序会响应方向的变化。

这对我来说很有用:

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    if (self.firstViewAppear) {
        [self.navigationController setNavigationBarHidden:YES];
        CGFloat duration = [UIApplication sharedApplication].statusBarOrientationAnimationDuration;
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:duration];
        self.navigationController.view.transform = CGAffineTransformIdentity;
        self.navigationController.view.transform = CGAffineTransformMakeRotation(M_PI*(90)/180.0);
        self.navigationController.view.bounds = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width);
        [UIView commitAnimations];
        self.firstViewAppear = NO;

    }
    self.view.frame = self.view.frame;
    [[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeRight animated:NO];

}

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

    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];
}

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscapeRight;
}

在programatic中,设置景观是什么意思?你是指布局控件、视图等吗?是的,在programatic中。我没有使用xib。给我任何代码。我有背景图像的景观“LBG.png”和肖像“BG.png”。如果(self.firstviewappeage){}出现错误,我应该将代码放在这里。@janagowtham in
中。如何设置firstviewappeage的属性。只需在.h文件中定义BOOL firstviewappeage属性。并且在init中设置默认值YES。