如果ipad处于横向模式,我想添加一个额外的div.是否有某种if语句可以找到它?
谢谢
我正在以HTML5格式在线发布免费图书,我说如果我可以为iPad优化它,即使我没有它也会很棒.
所以我开始研究设计,这个想法一直在我脑海里.我的设计只是为了在纵向模式下适合iPad屏幕,然后我尝试测试它,我发现Safari正在缩小整个网站,使页面适合其屏幕,这搞砸了我的设计并生气了我(我的坏我没有做太多的研究,苹果不会让我有iPad模拟器,因为我没有Mac!
无论如何..有什么方法可以强迫Safari忽略这种行为并让我的读者享受我的1:1比例设计?像CSS媒体查询或一些JavaScript的东西?
http://mmahgoub.com/thebook/foreword.html
谢谢
在我的IOS应用程序中,当我打开相机时,我在相机视图上放置了一个图像.它在纵向模式下看起来很不错.但当它改为横向模式时,它看起来有些奇怪.所以我想锁定UIImagePickerController纵向模式.
以下是我的ui图像选择器控制器的代码
UIImagePickerController *imgPkr = [[UIImagePickerController alloc] init];
imgPkr.delegate = self;
imgPkr.sourceType = UIImagePickerControllerSourceTypeCamera;
Run Code Online (Sandbox Code Playgroud)
它如何锁定在纵向模式....
首先,也许"风景"并不是更好的词语,但我现在想不到另一个.
我正在使用以下代码在ImageView中显示图像,但我在"肖像"(抬头)中使用设备拍摄的图像显示为侧面.
我的代码:
mImageView = (ImageView) findViewById(R.id.iv_photo);
Uri u = Uri.parse("content://media/external/images/media/7");
mImageView.setImageURI(u);
Run Code Online (Sandbox Code Playgroud)
XML:
<ImageView
android:id="@+id/iv_photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
Run Code Online (Sandbox Code Playgroud)
是的,"content:// media/external/images/media/7"是一条有效路径.
有任何想法吗?
我已成功使用ZXing条形码扫描库,但仅限于横向模式.
我也成功地将相机预览设置为纵向模式并正确显示(没有拉伸),但现在条形码根本不起作用.这是我在"CameraConfigurationManager.java"上对"setDesiredCameraParameters"所做的更改,以便正确显示相机:
void setDesiredCameraParameters(Camera camera)
{
Camera.Parameters parameters = camera.getParameters();
Log.d(TAG, "Setting preview size: " + cameraResolution);
setFlash(parameters);
setZoom(parameters);
camera.setDisplayOrientation(90);
parameters.set("rotation", 90);
parameters.setPreviewSize(cameraResolution.y, cameraResolution.x);
camera.setParameters(parameters);
}
Run Code Online (Sandbox Code Playgroud)
我尝试了其他地方提到的一些解决方案,但要么它们不起作用,要么它们有效但无法正确显示相机预览.示例: 如何在纵向模式下使用Zxing? http://code.google.com/p/zxing/issues/detail?id=178#c46 https://github.com/pplante/zxing-android/issues
当我完成后,我还需要自定义矩形的位置和大小到扫描.我知道我需要在"CameraManager.java"上更改"setManualFramingRect",但我不确定我是否正确操作.这是代码:
public void setManualFramingRect(Rect rect)
{
if (initialized)
{
Point screenResolution = configManager.getScreenResolution();
if (rect.right >= screenResolution.x)
rect.right = screenResolution.x - 1;
if (rect.left < 0)
rect.left = 0;
if (rect.bottom >= screenResolution.y)
rect.bottom = screenResolution.y - 1;
if (rect.top < 0)
rect.top = 0;
framingRect = rect;
Log.d(TAG, "Calculated …Run Code Online (Sandbox Code Playgroud) 鉴于随机数量的纵向和横向图像,我正在尝试编写PHP代码以输出两列高度相等的列:
我不确定我的方法在循环期间尝试输出html是否正确,或者是否更有意义分析数组并首先重新排序图像然后创建第二个循环以输出html.
我的代码有点脏,我的"array_splice"方法可能甚至不完全正确.如果您看到更好的方法,请随意废弃我的代码并向我展示更好的内容!任何帮助是极大的赞赏!!
<?php
$photoval = 0;
$totalcolumns = 0;
$totalphotos = count($photos);
for ($counter = 0; $counter < $totalphotos; $counter++) :
$photo = $photos[$counter];
if ($photoval == 0) echo " <div class=\"column\">\n";
if ($photo['orientation'] == "portrait" && $photoval >= $totalphotos/2) {
if ($counter == $totalphotos)
echo " </div>\n";
array_splice($photos, $counter, 1, array($photo));
continue;
}
?>
<div class="<? echo $photo['orientation'] ?> thumbnail">
<a href="<?php echo $photo['link'] ?>">
<img src="<?php if ($photo['orientation'] == "landscape") echo …Run Code Online (Sandbox Code Playgroud) 在iPhone模拟器和iPhone 3GS(iOS 6)上,我都无法将方向设置为纵向颠倒.我只有一个ViewController.我在其中添加了此代码:
-(BOOL) shouldAutorotate{
return YES;
}
-(UIInterfaceOrientation) preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationPortraitUpsideDown;
}
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationPortrait | UIInterfaceOrientationPortraitUpsideDown;
}
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
if (toInterfaceOrientation==UIInterfaceOrientationPortrait || toInterfaceOrientation==UIInterfaceOrientationPortraitUpsideDown) {
return YES;
}
return NO;
}
Run Code Online (Sandbox Code Playgroud)
我还将此添加到AppDelegate.m:
-(NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
return UIInterfaceOrientationPortrait | UIInterfaceOrientationPortraitUpsideDown;
}
Run Code Online (Sandbox Code Playgroud)
我还检查了plist文件,两个方向都存在.在我的故事板上,在Simulated Metrics Orientation设置为Inferred.我在applicationDidFinishLaunchingWithOptions中什么都不做,除了返回YES.我刚刚在这个ViewController中添加了一个UIImageView.是否有可能使这个方向有效?
Android视频在纵向时不适合视频的宽度,如何在纵向时使我的视频宽度适合我的视频宽度,当我将屏幕的方向更改为横向时我想要视频填充整个屏幕就像youtube应用程序一样.当在纵向时,视频将从屏幕的顶部到中间开始,并且在横向时用于填充整个屏幕.这是我尝试过的,我还添加了完整截图的链接
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="100" >
<VideoView
android:id="@+id/videoview"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="53" >
</VideoView>
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="7"
android:background="@drawable/top_bar"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/settings"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingTop="5dp" >
<ImageView
android:id="@+id/set"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/desc"
android:src="@drawable/settings" />
</LinearLayout>
<LinearLayout
android:id="@+id/low_tab"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingTop="5dp" >
<ImageView
android:id="@+id/low"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/desc"
android:src="@drawable/low" />
</LinearLayout>
<LinearLayout
android:id="@+id/high_tab"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingTop="5dp" >
<ImageView
android:id="@+id/high"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/desc"
android:src="@drawable/high" />
</LinearLayout>
<LinearLayout
android:id="@+id/audio_tab"
android:layout_width="70dp" …Run Code Online (Sandbox Code Playgroud) android portrait fullscreen android-layout android-videoview
我希望我的应用程序在纵向和反向纵向模式下工作。换句话说,我希望它在纵向模式下工作并使其可旋转180度!
我在清单中MainActivity的<activity>标记内使用以下代码。
android:screenOrientation="sensorPortrait"
Run Code Online (Sandbox Code Playgroud)
但是,这似乎仅适用于Android 4.1.2及更高版本。
在Android 4.2.2及更高版本上不起作用!
我在不同的电话上尝试过,结果相同!怎么解决呢?
android portrait rotation screen-orientation android-sensors
我不希望我的应用程序被美化,并始终是porttrait.So我使我的应用程序部署信息只设置肖像.但是当我需要在我的应用程序中显示任何图像或视频时,我需要横向模式以便更好地显示.
我可以通过检测设备方向的变化
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(orientationChanged:)
name:UIDeviceOrientationDidChangeNotification
object:[UIDevice currentDevice]];
- (void) orientationChanged:(NSNotification *)note
{
UIDevice * device = note.object;
switch(device.orientation)
{
case UIDeviceOrientationPortrait:
/* */
break;
case UIDeviceOrientationPortraitUpsideDown:
/* */
break;
case UIDeviceOrientationLandscapeLeft:
/* */
break;
case UIDeviceOrientationLandscapeRight:
/* */
break;
default:
break;
};
}
Run Code Online (Sandbox Code Playgroud)
但是,即使应用程序部署信息纵向被锁定,如何手动更改设备方向?
这不起作用
NSNumber *value=[NSNumber numberWithInt: UIDeviceOrientationLandscapeLeft];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
Run Code Online (Sandbox Code Playgroud)