小编maf*_*oso的帖子

如何在swift中检查设备方向是左侧还是右侧?

    if UIDeviceOrientationIsLandscape(UIDevice.currentDevice().orientation) {
        print("landscape")
    }
    if UIDeviceOrientationIsPortrait(UIDevice.currentDevice().orientation){
        print("portrait")
    }
Run Code Online (Sandbox Code Playgroud)

如何检查它的横向是左还是右?

device-orientation ios swift

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

如何更改AVPlayer的视频方向?

我想使用AVPlayer旋转视频的重放.有没有办法顺时针旋转90度?
这是一些代码:

self.player = AVPlayer(URL: NSURL(fileURLWithPath: dataPath))
playerLayer = AVPlayerLayer.init(player: self.player)
playerLayer.frame = view.bounds

playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
view.layer.addSublayer(playerLayer)
player.play()
Run Code Online (Sandbox Code Playgroud)

UPDATE

这个工作:

self.player = AVPlayer(URL: NSURL(fileURLWithPath: dataPath))
playerLayer = AVPlayerLayer.init(player: self.player)                                     
playerLayer.setAffineTransform(CGAffineTransformMakeRotation(CGFloat(M_PI))
playerLayer.frame = view.bounds        
playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
view.layer.addSublayer(playerLayer)
player.play()
Run Code Online (Sandbox Code Playgroud)

rotation avfoundation orientation ios swift

11
推荐指数
2
解决办法
8782
查看次数

相机只能在人像模式下快速拍照

如何将相机设置为横向模式?每次我拍照时,图像都会保存为人像图像。当设备处于横向模式时,照片看起来不错,但如果我在相机胶卷中看到它,它仍然是纵向模式。这是我的拍照功能:

// take a photo
@IBAction func takePhoto(sender: AnyObject) {
self.fullScreenView.hidden = false
self.recordButton.enabled = false
self.takephoto.enabled = false
self.recordButton.hidden = true
self.takephoto.hidden = true

session.startRunning()

// customize the quality level or bitrate of the output photo
session.sessionPreset = AVCaptureSessionPresetPhoto

// add the AVCaptureVideoPreviewLayer to the view and set the view in fullscreen
fullScreenView.frame = view.bounds
videoPreviewLayer.frame = fullScreenView.bounds
fullScreenView.layer.addSublayer(videoPreviewLayer)

// add action to fullScreenView
gestureFullScreenView = UITapGestureRecognizer(target: self, action: #selector(ViewController.takePhoto(_:)))
self.fullScreenView.addGestureRecognizer(gestureFullScreenView)

// add action to myView
gestureView = UITapGestureRecognizer(target: …
Run Code Online (Sandbox Code Playgroud)

camera landscape portrait ios swift

5
推荐指数
1
解决办法
1674
查看次数

如何使用JNI从C中的jobject获取值?

如何在C中获取Jobject的值?
JNI在C中使用并调用了Java函数。该参数是一个jobject,它看起来应该像这样:{"John", "Ganso", 5}
现在我想从该对象获取值,但我不知道如何。您对如何解决有什么建议?
我在C中的结构看起来像我在Java中的类。

我的代码如下所示:

JNIEXPORT void JNICALL
Java_model_JNIResultSet_printToFile(JNIEnv *env, jobject obj,
    jobject o) {

// How can I get values of jobject o?
}
Run Code Online (Sandbox Code Playgroud)

c java-native-interface object

4
推荐指数
2
解决办法
5175
查看次数

处理程序postDelayed-每秒打印一些内容

我想使用来打印当前秒handler。我精确地录制了视频,10 seconds并且想要设置TextView每秒的文本。

录制10秒的工作原理如下:

Handler handler = new Handler();
handler.postDelayed(new Runnable() {
    @Override
    public void run() {
           stopRecordingVideo();
    }
}, 11000);  // don't know why 11000 but it only works this way
Run Code Online (Sandbox Code Playgroud)

10秒钟后,该方法stopRecordingVideo()将执行。那么,如何每秒更改TextView的文本呢?

video android handler android-camera2

4
推荐指数
1
解决办法
4506
查看次数

ScrollView不会在swift中滚动

我有一个UIView并添加一个UIScrollView.scrollView内部是一个UIImageView.
我想通过按下按钮来缩放图像视图.如果图像视图被缩放,您应该能够滚动,但这不起作用.

目前我有:

self.imageView = UIImageView()
self.imageView.image = image
self.imageView.frame = self.contentView.bounds

self.scrollView = UIScrollView()
self.scrollView.frame = self.contentView.bounds
self.scrollView.contentSize = self.contentView.bounds.size
self.scrollView.addSubview(self.imageView)

self.contentView.addSubview(self.scrollView)
Run Code Online (Sandbox Code Playgroud)

然后:

@IBAction func zoomPicture() {
    if (scale <= 1.5) {
        scale = scale + 0.1
        scrollView.transform = CGAffineTransformMakeScale(scale, scale)
        scrollView.zoomScale = scale
        scrollView.maximumZoomScale = 1.5
        scrollView.minimumZoomScale = 1.0
        scrollView.contentSize = contentView.bounds.size
        scrollView.scrollEnabled = true
    }
}
Run Code Online (Sandbox Code Playgroud)

我的类也实现了UIScrollViewDelegate,我在viewDidLoad()函数中设置了委托.我还添加了这个viewForZoomingInScrollView功能.缩放工作,但我无法滚动.

uiscrollview uiimageview ios swift

3
推荐指数
1
解决办法
9907
查看次数

检查获取的对象是否是Swift中的图像或视频

我想检查一下latestObject的类型.这是一些代码:

allMedia = PHAsset.fetchAssetsWithOptions(fetchOptions)
let allPhotos = PHAsset.fetchAssetsWithMediaType(.Image, options: fetchOptions)
let allVideo = PHAsset.fetchAssetsWithMediaType(.Video, options: fetchOptions)
print("Found \(allMedia.count) media")
print("Found \(allPhotos.count) images")
print("Found \(allVideo.count) videos")

let latestObject: AnyObject! = allMedia.lastObject

// How to check what type latestObject is?
// I think something with mediaType but how is it exactly going?
Run Code Online (Sandbox Code Playgroud)

ios swift phasset

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

SQL Developer每次都会随机崩溃

我搜索了几个小时,但我不知道如何解决这个问题.

My SQL Developer (Version 4.1.5) crashes every time I execute it.     
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

 A fatal error has been detected by the Java Runtime Environment:

  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000, pid=4728, tid=0x00001638

 JRE version: Java(TM) SE Runtime Environment (8.0_101-b13) (build 1.8.0_101-b13)
 Java VM: Java HotSpot(TM) Client VM (25.101-b13 mixed mode windows-x86 )
 Problematic frame:
 C  0x00000000

 Failed to write core dump. Minidumps are not …
Run Code Online (Sandbox Code Playgroud)

java jvm oracle-sqldeveloper

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

Android中的特定时间后如何停止MediaRecorder?

我想在某个时间(例如5秒)后停止录制视频。
你知道怎么用MediaRecorder吗?

camera android android-mediarecorder android-camera2

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

如何使用Swift将照片库的最新照片添加到uiimageview?

有没有办法将我的照片库的最新照片添加到uiimageview?我几乎尝试了所有东西,但没有任何作用.

gallery uiimageview ios swift

1
推荐指数
1
解决办法
540
查看次数

如何快速拍摄高质量的视频/照片?

如何改善相机质量?我想拍摄全屏显示的图片/视频吗?如果我将会话预设设置为AVCaptureSessionPresetPhoto,则它是高质量和全屏模式,仅用于照片而非视频。我已经尝试了其他所有方法,但没有任何效果。当前,它看起来像这样:

在此处输入图片说明

编辑

为什么我的照片看起来像那样? 在此处输入图片说明

@IBAction func takePhoto(sender: AnyObject) {
    var imageViewBackground: UIImageView!
    self.fullScreenView.hidden = false
    self.recordButton.enabled = false
    self.takephoto.enabled = false
    self.recordButton.hidden = true
    self.takephoto.hidden = true

    session.startRunning()

    // add the AVCaptureVideoPreviewLayer to the view and sets the view in fullscreen
    fullScreenView.frame = view.bounds
    videoPreviewLayer.frame = fullScreenView.bounds
    fullScreenView.layer.addSublayer(videoPreviewLayer)

    // add action to fullScreenView
    gestureFullScreenView = UITapGestureRecognizer(target: self, action: #selector(ViewController.takePhoto(_:)))
    self.fullScreenView.addGestureRecognizer(gestureFullScreenView)

    // add action to myView
    gestureView = UITapGestureRecognizer(target: self, action: #selector(ViewController.setFrontpage(_:)))
    self.view.addGestureRecognizer(gestureView)

    if (preview == true) {
        if let videoConnection = …
Run Code Online (Sandbox Code Playgroud)

camera ios swift

1
推荐指数
1
解决办法
1322
查看次数

Interface Builder无法打开文档launchscreen.storyboard,因为它不存在

如何解决上述错误?我已经尝试了几乎所有内容,但没有任何效果。另外,“副本捆绑资源”文件夹也包含该文件。我不知道怎么了

xcode compiler-errors interface-builder

1
推荐指数
1
解决办法
2873
查看次数

如何在设备处于横向模式时更改约束?

有没有办法改变约束?如果设备处于横向模式,我想更改按钮的高度,centerX和centerY.

device-orientation ios swift

0
推荐指数
1
解决办法
1361
查看次数