if UIDeviceOrientationIsLandscape(UIDevice.currentDevice().orientation) {
print("landscape")
}
if UIDeviceOrientationIsPortrait(UIDevice.currentDevice().orientation){
print("portrait")
}
Run Code Online (Sandbox Code Playgroud)
如何检查它的横向是左还是右?
我想使用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) 如何将相机设置为横向模式?每次我拍照时,图像都会保存为人像图像。当设备处于横向模式时,照片看起来不错,但如果我在相机胶卷中看到它,它仍然是纵向模式。这是我的拍照功能:
// 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) 如何在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) 我想使用来打印当前秒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的文本呢?
我有一个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功能.缩放工作,但我无法滚动.
我想检查一下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) 我搜索了几个小时,但我不知道如何解决这个问题.
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) 我想在某个时间(例如5秒)后停止录制视频。
你知道怎么用MediaRecorder吗?
有没有办法将我的照片库的最新照片添加到uiimageview?我几乎尝试了所有东西,但没有任何作用.
如何改善相机质量?我想拍摄全屏显示的图片/视频吗?如果我将会话预设设置为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) 如何解决上述错误?我已经尝试了几乎所有内容,但没有任何效果。另外,“副本捆绑资源”文件夹也包含该文件。我不知道怎么了
有没有办法改变约束?如果设备处于横向模式,我想更改按钮的高度,centerX和centerY.
ios ×8
swift ×8
camera ×3
android ×2
uiimageview ×2
avfoundation ×1
c ×1
gallery ×1
handler ×1
java ×1
jvm ×1
landscape ×1
object ×1
orientation ×1
phasset ×1
portrait ×1
rotation ×1
uiscrollview ×1
video ×1
xcode ×1