小编Sim*_*ead的帖子

图像未出现在Today Extension Widget中

真的在努力解决这个问题:

图像(选中的勾号)出现在预览中并具有约束等但未显示在模拟器窗口小部件上.故事板上的其他元素显示确定但不是图像

在此输入图像描述

我相信我已正确设置了所有约束.图像视图有一个今日视图控制器的插座,没有其他代码提及(还没有开始编码它的功能,直到我看到它)

谢谢!

xcode ios ios-simulator swift

10
推荐指数
1
解决办法
2663
查看次数

如何在Swift 2/AVPlayer中恢复背景音频?

我正在学习Swift作为我的第一门编程语言.

中断后我已经挣了好几个小时才恢复背景音频播放(例如通话)

会发生什么:

  1. 当应用程序转到后台时,音频会继续播放(工作)
  2. 当被呼叫中断时,开始通知中断(工作)
  3. 通话结束时,获取中断结束通知(有效)
  4. 继续播放音频(不起作用 - 什么都听不到)

非常感谢任何帮助!谢谢

笔记:

  1. 该应用程序已注册为背景音频,并在中断前播放正常
  2. 我已经尝试过,没有时间延迟恢复播放 - 两个都没有工作

码:

import UIKit
import AVFoundation

var player: AVQueuePlayer!

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        do {
            try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
            try AVAudioSession.sharedInstance().setActive(true, withOptions: .NotifyOthersOnDeactivation)
        } catch { }
        let songNames = ["music"]
        let songs = songNames.map { AVPlayerItem(URL:
            NSBundle.mainBundle().URLForResource($0, withExtension: "mp3")!) }
        player = AVQueuePlayer(items: songs)

        let theSession = AVAudioSession.sharedInstance()
        NSNotificationCenter.defaultCenter().addObserver(self,
            selector:"playInterrupt:",
            name:AVAudioSessionInterruptionNotification,
            object: theSession)

        player.play()
    }

    func playInterrupt(notification: NSNotification) …
Run Code Online (Sandbox Code Playgroud)

audio avfoundation ios avplayer swift

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

为什么我的 Unity C# 脚本中的变量重置为 0

我有一个简单的项目,场景中有一个按钮,当点击该按钮时,会在此脚本中启动 StartWorking 函数:

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class DoWork : MonoBehaviour {

  public int Cash = 5;

  public void StartWorking() {
        Debug.Log (Cash);
        Debug.Log ("Ran!");
        Cash++;
        Debug.Log (Cash);
  }
}
Run Code Online (Sandbox Code Playgroud)

当运行并点击按钮时,控制台会说:

0
跑!
1

而不是预期:

5
跑!
6

知道为什么变量没有在类中保持它的初始值吗?

谢谢。

c# unity-game-engine

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