小编Mic*_*sou的帖子

如何使用Swift播放声音?

我想用Swift播放声音.

我的代码在Swift 1.0中运行,但现在它在Swift 2或更新版本中不再起作用了.

override func viewDidLoad() {
  super.viewDidLoad()

  let url:NSURL = NSBundle.mainBundle().URLForResource("soundName", withExtension: "mp3")!

  do { 
    player = try AVAudioPlayer(contentsOfURL: url, fileTypeHint: nil) 
  } catch _{
    return
  }

  bgMusic.numberOfLoops = 1
  bgMusic.prepareToPlay()

  if (Data.backgroundMenuPlayed == 0){
    player.play()
    Data.backgroundMenuPlayed = 1
  }
}
Run Code Online (Sandbox Code Playgroud)

avfoundation ios swift

108
推荐指数
9
解决办法
11万
查看次数

如何解除当前的ViewController并转到Swift中的另一个View

我是Swift的新手,我想知道如何关闭当前的视图控制器并转到另一个视图.

我的故事板如下所示:MainMenuView - > GameViewController - > GameOverView.我想解雇GameViewController转到GameOverView,而不是MainMenuView.

我在MainMenuView中使用以下代码:

@IBAction func StartButton(sender: UIButton) {
    let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
    let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("GameViewController") as! GameViewController
    self.presentViewController(nextViewController, animated:true, completion:nil)
    restGame()
}
Run Code Online (Sandbox Code Playgroud)

在GameViewController中,我使用此代码,但它不会忽略GameViewController.

let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("GameOverView") as! GameOverView
self.presentViewController(nextViewController, animated:true, completion:nil)
Run Code Online (Sandbox Code Playgroud)

这是我的GameOverView代码:

class GameOverView: UIViewController{
    // save the presenting ViewController
    var presentingViewController :UIViewController! = self.presentViewController

    override func viewDidLoad() {
        super.viewDidLoad()

    }

    @IBAction func ReplayButton(sender: UIButton) {
        restGame()
        didPressClose()
    }
    @IBAction …
Run Code Online (Sandbox Code Playgroud)

viewcontroller ios segue swift

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

无法验证iPhone开发人员应用程序

我正在使用Xcode 7 beta 4和iOS 9.我在使用Xcode 7具有的新功能在我的设备上启动我的应用程序时遇到了麻烦,这使我们可以在没有Apple Developer Program的情况下尝试应用程序

这是我在尝试信任和验证应用时从Profile获得的内容.它一直告诉我,我需要连接到互联网,但我总是连接.我尝试删除我的个人资料和我的应用程序并重新启动手机,但它不起作用.

有什么建议?

在此输入图像描述

在此输入图像描述

xcode ios xcode7-beta4

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

标签 统计

ios ×3

swift ×2

avfoundation ×1

segue ×1

viewcontroller ×1

xcode ×1

xcode7-beta4 ×1