调用equals(“”);(Calling equals(“”); by itself compiles and runs)
我注意到调用
equals("");
在类的方法中不会在Eclipse
产生任何错误。 我从来没有见过.equals没有像string1.equals(string2);
。package voodoo; public class Equals { public void method(){ equals(""); } }
这里发生了什么,以及什么时候会自动调用
equals()
。如果我将它放入
JUnit
进行测试,它就会运行并通过。I've noticed that calling
equals("");
in a method of a class is not generating any error withinEclipse
. I've never seen .equals called without something likestring1.equals(string2);
.package voodoo; public class Equals { public void method(){ equals(""); } }
What's going on here and when would calling
equals()
by itself ever be used?If I put that into a
JUnit
to test, it runs and passes.
原文:https://stackoverflow.com/questions/32486905
最满意答案
我会假设你在这里瞄准iOS 7(使用XCode 5.1,我认为我是对的)。
首先,你必须明白,为了打开超过40个景观中的一个视图,你的应用应该允许横向和纵向的界面方向。 默认情况下是这样,但您可以在您的目标设置,
General
选项卡,Deployment Info
部分中查看它(请参阅下面的屏幕截图)。然后,因为您允许横向和纵向整个应用程序,您将不得不告诉每个只有纵向的
UIViewController
,它不应该自动旋转,添加此方法的实现:- (BOOL)shouldAutorotate { return NO; }
最后,对于您的特定景观专用控制器,并且因为您说您以模态方式呈现它,您可以只实现这些方法:
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationLandscapeLeft; // or Right of course } - (UIInterfaceOrientationMask)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; }
希望这会有所帮助,
I am gonna suppose you are targeting iOS 7 here (using XCode 5.1, I think I am right).
First, you have to understand that in order to open even just one view out of over 40 in landscape, your app should allow both landscape and portrait interface orientations. It is the case by default, but you can check it in your target's settings,
General
tab,Deployment Info
section (see screenshot below).Then, because you allowed both landscape and portrait for the entire app, you will have to tell every portrait-only
UIViewController
that it should not autorotate, adding this method's implementation:- (BOOL)shouldAutorotate { return NO; }
Finally, for your specific landscape-only controller, and because you said you are presenting it modally, you can just implement these methods:
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationLandscapeLeft; // or Right of course } - (UIInterfaceOrientationMask)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; }
Hope this will help,
相关问答
更多-
只有一个查看横向模式(Only ONE VIEW landscape mode)[2022-06-10]
我会假设你在这里瞄准iOS 7(使用XCode 5.1,我认为我是对的)。 首先,你必须明白,为了打开超过40个景观中的一个视图,你的应用应该允许横向和纵向的界面方向。 默认情况下是这样,但您可以在您的目标设置, General选项卡, Deployment Info部分中查看它(请参阅下面的屏幕截图)。 然后,因为您允许横向和纵向整个应用程序,您将不得不告诉每个只有纵向的UIViewController ,它不应该自动旋转,添加此方法的实现: - (BOOL)shouldAutorotate { re ... -
如果您使用UINavigationController作为基本视图控制器,那么您提供的代码段根本不起作用。 因为您要将该代码添加到UIViewController但它已经嵌入到UINavigationController 。 要解决此问题,您必须创建UINavigationController的子类,并将该横向相关代码添加到该子类。 然后将此子类分配给Storyboard的基本导航控制器。 然后这个问题就会解决。 这是您的导航控制器子类'.h文件 @interface YourCustomNavigatio ...
-
在ios 6中,支持界面方向的方法已经改变。 为了支持两个版本中的接口方向,我们需要检查os版本并相应地编写代码。 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } 支持新版本 - (NSUInteger)supportedInterf ...
-
使用像 imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; 并从上面的代码中设置leftmargin,右边距 Use like imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; and also set leftmargin ,r ...
-
在你的.h文件中 @property (strong, nonatomic) MPMoviePlayerController *moviePlayer; 并在你的.m文件中合成该属性 @synthesize moviePlayer = _moviePlayer; 我有我的资源文件夹中的电影文件,相应地更改你的名字: _moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:[NSURL fileURLWi ...
-
在横向模式下捕捉视图(Catch View in Landscape Mode)[2022-04-30]
像这样做: -(void)viewDidLoad { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged) name:UIDeviceOrientationDidChangeNo ... -
你不能。 记下文件 : UIImagePickerController类仅支持纵向模式。 此类旨在按原样使用,不支持子类。 这有点多,但是您可以使用AssetsLibrary框架访问图像列表并创建自己的图像选择器。 You can't. Quoth the documentation: The UIImagePickerController class supports portrait mode only. This class is intended to be used as-is and does ...
-
我自己找到了解决方案;)我有来自https://developer.android.com/training/system-ui/immersive.html#nonsticky的片段。 它不正确。 我在showSystemUI()中更改了标志,并且所有的作品都完美无缺! private void showSystemUI() { activity.setFitsSystemWindows(true); decorView.setSystemUiVisibility(View.SYSTEM_ ...
-
在横向模式下向窗口添加新视图会以纵向模式呈现视图(Adding new view to Window whilst in Landscape mode renders view in portrait mode)[2020-02-04]
[self.splitViewController.view addSubview:newController.view]; [self.splitViewController.view addSubview:newController.view]; -
Android禁用横向模式(Android disable landscape mode)[2022-09-22]
android:configChanges="orientation|keyboardHidden|keyboard" android:configChanges="orientation|keyboardHidden|keyboard"