我正在使用Swift的AVFoundation来捕获iOS中的视频.但是当我使用Apple Music/Spotify播放歌曲然后单击我的应用程序的录制按钮时,它会暂停/停止音乐然后录制视频.我该如何防止这种情况发生?
这是我的代码:
@IBAction func record_video(sender: AnyObject) {
var initialOutputURL = NSURL(fileURLWithPath: "")
do
{
initialOutputURL = try NSFileManager.defaultManager().URLForDirectory(.DocumentDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: true).URLByAppendingPathComponent("output").URLByAppendingPathExtension("mov")
}catch
{
print(error)
}
if !isRecording
{
isRecording = true
if let outputs = captureSession.outputs as? [AVCaptureOutput] {
for output in outputs {
captureSession.removeOutput(output)
}
}
do
{
try audioSession.setCategory(AVAudioSessionCategoryAmbient)
}
catch
{
print("Can't Set Audio Session Category: \(error)")
}
AVAudioSessionCategoryOptions.MixWithOthers
do
{
try audioSession.setMode(AVAudioSessionModeVideoRecording)
}
catch
{
print("Can't Set Audio Session Mode: \(error)")
} …Run Code Online (Sandbox Code Playgroud) 我已经下载了最新版本的XCode来测试iOs 10 Beta中的项目.当我打开它时,XCode问我是否要将我的项目转换为Swift 3.执行此操作后,出现了一个错误:
无法覆盖已标记为"不可用"的"locationManager":在iOS 7及更早版本中弃用的API在Swift中不可用
我的代码如下:
func locationManager(_ manager: CLLocationManager, didUpdateToLocation newLocation: CLLocation, fromLocation oldLocation: CLLocation) {
locationManager.stopUpdatingLocation()
currentUserLocation = newLocation
}
Run Code Online (Sandbox Code Playgroud)
是否有另一个"未弃用"功能来实现相同的结果?
谢谢!
可可豆 1.1.1
Xcode 8.1 测试版
想要添加 Firebase/Core pod
播客文件
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'AddPodAdMob' do
source 'https://github.com/CocoaPods/Specs.git' do
use_frameworks!
pod 'Firebase/Core'
end
end
Run Code Online (Sandbox Code Playgroud)
如果不添加源,它就不会创建.xcworkspace文件。
现在在 pod install 命令之后显示这个。
Pod installation complete! There are 0 dependencies from the Podfile and 0 total pods installed.
[!] The Podfile does not contain any dependencies.
Run Code Online (Sandbox Code Playgroud)
任何帮助请...
我在我的应用程序中集成了 APNS,要求是在后台应用程序时保持通知计数。例如,我们在后台收到通知,其中有关键计数器计数,即每个通知中的动态变化,当应用程序处于后台或应用程序强制关闭时,是否可以在 iOS 中处理。
我现在在我的应用程序中设置了 Firebase 通知,当我发送消息时,消息会发送给我应用程序的所有用户。(我目前通过 Firebase 控制台发送消息)。我想要另一种不涉及 Firebase 控制台的推送通知发送方式,我相信 HTTP Post 是一种简单的方法。如何使用 HTTP Post 远程发送推送通知?
我想从我自己的位置到预定义的位置获取路线.我可以通过在浏览器中打开它来完成它,但它只需要在应用程序中完成.有没有办法绘制路线并将其更新为当前位置的变化?
我正在使用以下代码在浏览器中打开.我希望它只保留在应用程序中
let url = URL(string: "http://maps.apple.com/?saddr=\(lat),\(long)&daddr=\(latgest),\(longgest)&dirflg=d")!
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
else
{
UIApplication.shared.openURL(url)
}
Run Code Online (Sandbox Code Playgroud) 我正在将Realm用于我的笔记应用程序。我以前使用过核心数据,现在正在将核心数据迁移到领域,但我遇到了麻烦!像这样重新排序对象会导致错误。
do {
let realm = try Realm()
let source = myNote[sour!.row]
try realm.write() {
myNote.remove(objectAtIndex: sourceIndexPath!.row)
myNote.insert(source, at: destensionIndexPath!.row)
}
}
catch {
print("handle error")
}
Run Code Online (Sandbox Code Playgroud)
所以我向我的对象添加了 orderPosition属性
dynamic var orderPosition: Int = 0
Run Code Online (Sandbox Code Playgroud)
并将tableView moveRowAtIndexPath更改为此 ReorderingRealmResultsInTableView.swift
但这并没有多大帮助。那么如何重新排序领域中的对象?
ios ×8
swift ×3
swift3 ×3
xcode ×3
firebase ×2
avfoundation ×1
cocoapods ×1
http ×1
ios10 ×1
mkmapview ×1
objective-c ×1
realm ×1
storyboard ×1
uibutton ×1
uitableview ×1
video ×1