小编Ben*_*Ben的帖子

为什么关于UIColor whiteColor的声明评估为false?

只是测试一下......当我摇动它时,我试图让我的视图的背景颜色切换....但只有当它是当前的某种颜色.

-(void)viewDidLoad{    
    self.view.backgroundColor = [UIColor whiteColor];
}


-(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event{       
    if(event.subtype == UIEventSubtypeMotionShake)
    {
        [self switchBackground];
    }
}


-(void)switchBackground{        
//I can't get the if statement below to evaluate to true - UIColor whiteColor is
// returning something I don't understand or maybe self.view.backgroundColor 
//is not the right property to be referencing?

    if (self.view.backgroundColor == [UIColor whiteColor]){

        self.view.backgroundColor = [UIColor blackColor];
    }    
}
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c

2
推荐指数
1
解决办法
985
查看次数

模型如何与View Controller对话?

这是我无法工作的东西......我可以让视图控制器与我的自定义对象进行对话......但是如何从我的对象向视图控制器发送消息?

从myViewController到myObject的消息看起来像[myObject doSomething].

相反的消息会是什么样的?以其他方式发送消息甚至是否有意义?

非常感谢您的帮助!

iphone model-view-controller objective-c

0
推荐指数
1
解决办法
1120
查看次数