从另一个类更新BOOL值

时间:2013-02-15 21:42:03

标签: ios ios5 uiviewcontroller boolean implicit-conversion

我已经设置了一个包含以下内容的类: MESSidePanelViewControllerSubClass 头文件

@property BOOL setLandscapeOK;

Imp文件

- (NSInteger)supportedInterfaceOrientations {
    // Restriction for the welcome page to only allow potrait orientation

    if (setLandscapeOK == YES) {
        NSLog(@"Reveal-setting all");
        return UIInterfaceOrientationMaskAll;
    }
    NSLog(@"Reveal-setting portrait");
    return UIInterfaceOrientationMaskPortrait;
}

我现在想要更新另一个文件(视图控制器)的值 LoginViewController 其他视图控制器imp文件

- (NSInteger)supportedInterfaceOrientations {
    // Restriction for the welcome page to only allow potrait orientation
    NSLog(@"Login-supportInterfaceOrientations");
    MESSidePanelViewControllerSubClass* setLandscapeOK = YES;
    return UIInterfaceOrientationMaskAll;
}

我收到错误:

Implicit conversion of 'BOOL' (aka 'signed char') to 'MESSidePanelViewControllerSubClass *' is disallowed with ARC

我应该如何更新另一个文件中的BOOL值?

2 个答案:

答案 0 :(得分:0)

这一行错了:

MESSidePanelViewControllerSubClass* setLandscapeOK = YES;

它应该是这样的:( mESSidePanelViewControllerSubClass也可能是iVar并在supportedInterfaceOrientations方法之外的某处实例化。)

 MESSidePanelViewControllerSubClass *mESSidePanelViewControllerSubClass = [MESSidePanelViewControllerSubClass alloc] init];

然后:

mESSidePanelViewControllerSubClass.setLandscapeOK = YES;

已修改为delegate添加链接。

答案 1 :(得分:0)

-supportedInterfaceOrientations中的MESSidePanelViewControllerSubClass不应该总是返回UIInterfaceOrientationMaskPortrait吗?如果将MESSidePanelViewControllerSubClass的实例作为子视图控制器推送,那么强制您的UI方向不是纵向吗?你试过吗?