标签: orientation

没有调用Android onConfigurationChanged

告诉Android onCreate()在方向改变时不打电话我遇到了麻烦.我已经添加android:configChanges="orientation"到我的清单中但仍然onCreate()调用了方向更改.这是我的代码.

AndroidManifest.xml中

<activity android:name="SearchMenuActivity" android:theme="@android:style/Theme.NoTitleBar" android:configChanges="orientation"></activity>
Run Code Online (Sandbox Code Playgroud)

SearchMenuActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Set the current layout to the search_menu
    setContentView(R.layout.search_menu_activity);

    Log.d(TAG, "onCreate() Called");
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
    //don't reload the current page when the orientation is changed
    Log.d(TAG, "onConfigurationChanged() Called");
    super.onConfigurationChanged(newConfig);
}
Run Code Online (Sandbox Code Playgroud)

和我的LogCat输出

06-23 12:33:20.327: DEBUG/APP(2905): onCreate() Called
//Orientation Changes
06-23 12:33:23.842: DEBUG/APP(2905): onCreate() Called
Run Code Online (Sandbox Code Playgroud)

有谁知道我做错了什么?谢谢.

java configuration android orientation

40
推荐指数
4
解决办法
5万
查看次数

水平UITableView

我希望在我的ipad应用程序中实现一个布局,它有一个非常适合的视图,可以向左和向右滚动,而不是向上和向下滚动:

所以而不是

第1行第2行第3行(垂直滚动)它将是:第1行,第2行,第3行(水平滚动)

我已经看到UItableView被设计为仅进行垂直滚动,因此进行转换不会产生预期的效果.是否有一种标准方法可以利用uitableview提供的数据源提供商?
我基本上想做的事情类似于Ipad上的BBC新闻阅读器应用程序与故事列表可供选择.

谢谢

iphone orientation ipad

39
推荐指数
5
解决办法
5万
查看次数

保存UIImage,以错误的方向加载它

我使用以下代码来保存和加载我从库中选择的图像或使用相机:

//saving an image
- (void)saveImage:(UIImage*)image:(NSString*)imageName {
    NSData *imageData = UIImagePNGRepresentation(image); //convert image into .png format.
    NSFileManager *fileManager = [NSFileManager defaultManager];//create instance of NSFileManager
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //create an array and store result of our search for the documents directory in it
    NSString *documentsDirectory = [paths objectAtIndex:0]; //create NSString object, that holds our exact path to the documents directory
    NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png", imageName]]; //add our image to the path
    [fileManager createFileAtPath:fullPath contents:imageData attributes:nil]; //finally …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c orientation uiimageview ipad

39
推荐指数
2
解决办法
2万
查看次数

如何在UICollectionView中更改滚动方向?

我的故事板iOS应用程序中有一个UICollectionView.当设备处于纵向方向时,我希望它能够垂直滚动,当它在Landscaper中时,我希望它能够水平滚动.

在UICollectionView中,我可以看到scrollEnabled成员,但我看不到设置滚动方向的方法.我错过了什么吗?

scroll objective-c orientation ios uicollectionview

36
推荐指数
5
解决办法
6万
查看次数

在iPad上确定UIInterfaceOrientation

在这种情况下我不需要指定方向,我只需要检测它,但我遇到了麻烦.我有条件代码,只能在肖像中工作,如果设备在横向,我需要做其他事情.由于deviceOrientation不一定与interfaceOrientation相同,我无法想出一种测试纵向模式的方法.

我在Google上找到的大多数教程都是强制横向或进行某种轮换的方法.我唯一想做的就是确定方向是什么.这是我的代码,它不起作用:

-(void)viewDidLoad {
    [super viewDidLoad];
    //currentOrientation is declared as UIInterfaceOrientation currentOrientation
    currentOrientation = [[UIApplication sharedApplication] statusBarOrientation];
NSLog(@"%@",currentOrientation);  // == NULL
}
Run Code Online (Sandbox Code Playgroud)

我需要有条件地确定interfaceOrientation和program的值.谢谢你的帮助!

iphone orientation ipad

35
推荐指数
3
解决办法
5万
查看次数

iPhone AVFoundation摄像头方向

我一直在试图让我的头发试图让AVFoundation相机以正确的方向(即设备方向)拍摄图片,但我无法让它工作.

我看过教程,我看过WWDC演示文稿,我已经下载了WWDC示例程序,但即便如此也没有.

我的应用程序的代码是......

AVCaptureConnection *videoConnection = [CameraVC connectionWithMediaType:AVMediaTypeVideo fromConnections:[imageCaptureOutput connections]];
if ([videoConnection isVideoOrientationSupported])
{
    [videoConnection setVideoOrientation:[UIApplication sharedApplication].statusBarOrientation];
}

[imageCaptureOutput captureStillImageAsynchronouslyFromConnection:videoConnection
                                                completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error)
{
    if (imageDataSampleBuffer != NULL)
    {
        //NSLog(@"%d", screenOrientation);

        //CMSetAttachment(imageDataSampleBuffer, kCGImagePropertyOrientation, [NSString stringWithFormat:@"%d", screenOrientation], 0);

        NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
        UIImage *image = [[UIImage alloc] initWithData:imageData];

        [self processImage:image];
    }
}];
Run Code Online (Sandbox Code Playgroud)

(processImage使用与WWDC代码相同的writeImage ...方法)

并且WWDC应用程序的代码是......

AVCaptureConnection *videoConnection = [AVCamDemoCaptureManager connectionWithMediaType:AVMediaTypeVideo fromConnections:[[self stillImageOutput] connections]];
        if ([videoConnection isVideoOrientationSupported]) {
            [videoConnection setVideoOrientation:AVCaptureVideoOrientationPortrait];
        }

[[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:videoConnection
                                                             completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
                                                                 if …
Run Code Online (Sandbox Code Playgroud)

iphone camera avfoundation orientation

35
推荐指数
3
解决办法
3万
查看次数

如何更改GENYMOTION屏幕方向?

是否可以更改genymotion模拟器的方向?是否有拍摄或设置来改变这个?

我试图谷歌它但没有找到它.任何建议将不胜感激,谢谢.

android landscape emulation orientation genymotion

35
推荐指数
3
解决办法
2万
查看次数

屏幕方向锁定

是否有可靠的方法来锁定所有Android设备上的屏幕方向?以下代码适用于我的Nexus S和其他手机,但出于某种原因,ROTATION_90对应于Xoom上的SCREEN_ORIENTATION_REVERSE_PORTRAIT.

有没有办法可靠地将旋转映射到方向?

private void lockScreenOrientation() {
    if (!mScreenOrientationLocked) {
        final int orientation = getResources().getConfiguration().orientation;
        final int rotation = getWindowManager().getDefaultDisplay().getOrientation();

        if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) {
            if (orientation == Configuration.ORIENTATION_PORTRAIT) {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            }
            else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            }
        }
        else if (rotation == Surface.ROTATION_180 || rotation == Surface.ROTATION_270) {
            if (orientation == Configuration.ORIENTATION_PORTRAIT) {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
            }
            else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
            }
        }

        mScreenOrientationLocked = true;
    }
}

private void unlockScreenOrientation() { …
Run Code Online (Sandbox Code Playgroud)

android locking screen rotation orientation

34
推荐指数
4
解决办法
4万
查看次数

iPhone上的响应式网站 - 从景观到肖像旋转的不需要的白色空间

我正在创建一个响应式网站,并且刚刚注意到在iPhone上查看时我的内容页面中出现了一种奇怪的行为.在纵向模式下加载时,以及旋转到横向时,它可以正确缩放.然而,当旋转回到肖像时,页面似乎向左移动,或者没有正确缩放,并且在右侧有一条白色空间.当用户可以向左滑动页面时,这个空白区域似乎也在第一次加载时出现

这不是使解释进一步复杂化,而是指向发生此行为的示例页面的链接.看看iPhone,然后看一下没有这个问题的主页.

如果你需要进一步了解,请知道:)

iphone whitespace rotation orientation responsive-design

34
推荐指数
3
解决办法
5万
查看次数

处理方向更改的最佳做法:Android

我正在通过各种实践来处理线程和AsyncTask的方向更改.我遇到了以下解决方案:

  1. Attach-detach模型:在保留实例的同时为线程和AsyncTask附加和分离活动.(来源:1,2)

  2. 无头片段方式:使用非UI /无头片段执行所有与线程相关的操作,并在配置更改时保留其实例.(来源:1,2)

有没有其他方法来处理这种情况?建议的做法是什么?我问这个是因为我在Android文档的任何地方都找不到通用的解决方案.

multithreading android fragment orientation

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