只是测试一下......当我摇动它时,我试图让我的视图的背景颜色切换....但只有当它是当前的某种颜色.
-(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) 这是我无法工作的东西......我可以让视图控制器与我的自定义对象进行对话......但是如何从我的对象向视图控制器发送消息?
从myViewController到myObject的消息看起来像[myObject doSomething].
相反的消息会是什么样的?以其他方式发送消息甚至是否有意义?
非常感谢您的帮助!