小编Ron*_*nit的帖子

iOS:AVSpeechSynthesizer:需要在Headphone左声道中说出文字

我正在使用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)

text-to-speech avfoundation ios swift

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

在tableViewCell中添加UIImageView插件时出错

我已经制作了自定义tableViewCell,其中我添加了2个标签和一个UIImageView我能够添加Label Outlet.我添加了UIImageView Outlet但添加后我收到错误 - "带有Objective-C选择器的'imageView'获取'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''使用xcode 8.2 swift 3.0 在此输入图像描述

uiimageview tableviewcell ios swift

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

我们可以为UILabel添加Tap手势吗?

我在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)

uilabel ios uitapgesturerecognizer swift3

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