我正在使用AVTpeechSynthesizer for TextToSpeech.我必须在HeadPhone左侧的Channel(Mono 2)中演奏.我有以下设置输出通道.
func initalizeSpeechForRightChannel(){
let avSession = AVAudioSession.sharedInstance()
let route = avSession.currentRoute
let outputPorts = route.outputs
var channels:[AVAudioSessionChannelDescription] = []
//NSMutableArray *channels = [NSMutableArray array];
var leftAudioChannel:AVAudioSessionChannelDescription? = nil
var leftAudioPortDesc:AVAudioSessionPortDescription? = nil
for outputPort in outputPorts {
for channel in outputPort.channels! {
leftAudioPortDesc = outputPort
//print("Name: \(channel.channelName)")
if channel.channelName == "Headphones Left" {
channels.append(channel)
leftAudioChannel = channel
}else {
// leftAudioPortDesc?.channels?.removeObject(channel)
}
}
}
if channels.count > 0 {
if #available(iOS 10.0, *) {
print("Setting Left Channel") …Run Code Online (Sandbox Code Playgroud) 我在UIView中添加了Label并创建了它的插座,然后在UITapGestureRecognizer的帮助下我添加了功能,但是当我点击或点击标签时.标签文本不会更改.我搜索了类似的问题,我得到的答案也是我写的,但标签文字仍未改变.用Swift 3.0编写的代码.这是我写的代码 -
import UIKit
class testingViewController: UIViewController {
@IBOutlet weak var testLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
let tap:UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(showDatePicker))
tap.numberOfTouchesRequired = 1
tap.numberOfTapsRequired = 1
testLabel.addGestureRecognizer(tap)
testLabel.isUserInteractionEnabled = true// after adding this it worked
// Do any additional setup after loading the view.
}
func showDatePicker(){
print("testing")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, …Run Code Online (Sandbox Code Playgroud)