小编Xin*_*gou的帖子

播放视频时,avplayer没有声音

这是我的所有代码播放mp4,mp4播放但没有声音

import UIKit

import AVFoundation
class ViewController: UIViewController {

@IBOutlet weak var containerView: UIView!

var playerLayer:AVPlayerLayer!
var player:AVPlayer!
override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    let path = NSBundle.mainBundle().pathForResource("huoguo", ofType: "mp4")
    let url = NSURL(fileURLWithPath: path!)
    let asset = AVAsset(URL: url)
    let playerItem = AVPlayerItem(asset: asset)
    self.player = AVPlayer(playerItem: playerItem)
    self.playerLayer = AVPlayerLayer(player: player)
    self.playerLayer.frame = CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, UIScreen.mainScreen().bounds.width * 9 / 16)
    self.containerView.layer.addSublayer(playerLayer)
    //self.playerLayer.player?.volume = 1
    self.playerLayer.player?.play() …
Run Code Online (Sandbox Code Playgroud)

ios avplayer

25
推荐指数
4
解决办法
9218
查看次数

当使用jenkins运行测试时,iOS无法启动模拟器

我将使用jenkins为我的iOS应用程序,我在互联网上关注一些博客并使用jenkins成功构建,但是当我想为我的项目运行测试时,我收到此错误:

2015-12-10 16:58:06.105 xcodebuild[6635:91852]  iPhoneSimulator: Could not launch simulator: -10810
2015-12-10 16:58:06.174 xcodebuild[6635:92068]  iPhoneSimulator: Could not launch simulator: -10810
** TEST FAILED **
Run Code Online (Sandbox Code Playgroud)

我已经尝试了xcodeplugin,只是jenkins中的一个简单的shell命令,他们都给了我这个错误.我的shell命令如下:

xcodebuild  -scheme XcodeBulidDemo -destination 'platform=iOS Simulator,name=iPhone 6' -configuration Debug test
Run Code Online (Sandbox Code Playgroud)

我曾尝试在我的项目下的终端中运行此命令,它可以获得测试结果.

我真的不明白错误"iPhoneSimulator:无法启动模拟器:-10810"是什么意思,任何人都可以给我一些建议..

ios jenkins

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

UIView的systemLayoutSizeFitting方法如何工作?

在文档中:

返回满足其所包含约束的视图的大小.

好的,我在storyboard中创建了一个视图,并添加了约束:

yellowview.leading = self.view.leading

yellow view.trailing = self.view.trailing

yellow view.bottom = self.view.bottom

yelloview.height = 128
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

现在我打印出来systemLayoutSizeFittingSize,我希望它是UIScreen宽度和128高度.但结果是:

====UILayoutFittingCompressedSize==
(0.0, 128.0)
====UILayoutFittingExpandedSize==
(10000.0, 128.0)
Run Code Online (Sandbox Code Playgroud)

======================================

然后我创建一个视图并通过代码添加约束:

    let btn :UIButton = {
        let btn = UIButton(type: .Custom)
        btn.backgroundColor = UIColor.redColor()
        btn.translatesAutoresizingMaskIntoConstraints = false
        return btn
    }()

override func viewDidLoad() {
    super.viewDidLoad()
    self.view.addSubview(btn)
    btn.leadingAnchor.constraintEqualToAnchor(self.view.leadingAnchor, constant: 100).active = true
    btn.trailingAnchor.constraintEqualToAnchor(self.view.trailingAnchor, constant: -100).active = true
    btn.topAnchor.constraintEqualToAnchor(self.view.topAnchor, constant: 100).active = true
    btn.bottomAnchor.constraintEqualToAnchor(self.view.bottomAnchor, constant: -100).active = true
}
Run Code Online (Sandbox Code Playgroud)

它显示很好:

在此输入图像描述

现在打印出来了systemLayoutSizeFittingSize: …

uiview ios

6
推荐指数
0
解决办法
1582
查看次数

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

如何使用 jazzy 来记录我的 swift 项目?

我想记录我的 swift 项目,我在 github 上找到了 jazzy。查看指南后,我创建了一个新的简单项目并想尝试一下,这是我ViewController的一些文档信息:

import UIKit
/**
a view controller
*/
class ViewController: UIViewController {
// MARK: property
/// a simple var
var hello = 200

// MARK: Func
/// view did load
override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    print(add(2, b: 2))
}
/// did receiveMemoryWarning
override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

/// a document …
Run Code Online (Sandbox Code Playgroud)

document ios swift jazzy

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

标签 统计

ios ×5

avplayer ×1

document ×1

jazzy ×1

jenkins ×1

storyboard ×1

swift ×1

uiview ×1

xcode8 ×1