这是关于shouldAutoRotateToInterfaceOrientation
视图控制器方法中return语句的语法的一个相当基本的问题.
为了允许除了颠倒的肖像模式之外的所有视图,我实现了以下代码块:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
Run Code Online (Sandbox Code Playgroud)
退货声明究竟在做什么?我知道它返回一个布尔变量,但它是如何确定是返回true还是false?这是return语句中的一种隐式if语句吗?即:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown)
return YES;
}
Run Code Online (Sandbox Code Playgroud)
技术上是一样的,只是更明确地说明了吗?
谢谢你的澄清!