我一直无法找到获得设备高度的方法.有人可以给我一个指针或组合一个短脚本,获取设备的高度并打印出来吗?只有在迅速.谢谢!
我使用下面的代码将UIImageViews旋转到不同的角度.
self.imageOne.transform = CGAffineTransformMakeRotation(CGFloat(-rotation))
self.imageTwo.transform = CGAffineTransformMakeRotation(CGFloat(-rotation-0.1))
self.imageThree.transform = CGAffineTransformMakeRotation(CGFloat(-change+0.1))
Run Code Online (Sandbox Code Playgroud)
是否有任何方法可以使图像从顶部而不是中间转动?我想避免让精灵参与,因为我从未使用它们,也不知道如何在单个视图应用程序中使精灵工作.谢谢你的时间.
我一直无法使下面的代码一遍又一遍地重复audioURL的声音.现在它只是在视图打开时播放一次,然后停止.
import UIKit
import AVFoundation
class aboutViewController: UIViewController {
var audioUrl = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("chimes", ofType: "wav")!)
var audioEngine = AVAudioEngine()
var myPlayer = AVAudioPlayerNode()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
audioEngine.attachNode(myPlayer)
var audioFile = AVAudioFile(forReading: audioUrl, error: nil)
var audioError: NSError?
audioEngine.connect(myPlayer, to: audioEngine.mainMixerNode, format: audioFile.processingFormat)
myPlayer.scheduleFile(audioFile, atTime: nil, completionHandler: nil)
audioEngine.startAndReturnError(&audioError)
myPlayer.play()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
我一直在努力寻找一种方法来启动带有方形实时视图的UIImagePickerController,并让它拍摄方形图片.我现在用于启动相机的代码如下
func takePicture() {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.PhotoLibrary){
println("Button capture")
var imag = UIImagePickerController()
imag.delegate = self
imag.sourceType = UIImagePickerControllerSourceType.Camera
//imag.mediaTypes = [kUTTypeImage];
imag.allowsEditing = false
self.presentViewController(imag, animated: true, completion: nil)
}
}
func imagePickerController(picker: UIImagePickerController!, didFinishPickingImage image: UIImage!, editingInfo: NSDictionary!) {
let selectedImage : UIImage = image
//var tempImage:UIImage = editingInfo[UIImagePickerControllerOriginalImage] as UIImage
var newImage: UIImage = resizeImageWithImage(selectedImage, size: CGSize(width: 320, height: 568))
datImage.image=newImage
let paths: NSArray = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
let documentsDir: NSString = paths.objectAtIndex(0) as NSString
var dateFormat = …Run Code Online (Sandbox Code Playgroud) 所以下面的代码应该一遍又一遍地重放chimes.wav文件,音高更高,但是底部的错误会崩溃.任何人都可以找到导致此错误的原因吗?
import UIKit
import AVFoundation
class aboutViewController: UIViewController {
var audioEngine: AVAudioEngine = AVAudioEngine()
var audioFilePlayer: AVAudioPlayerNode = AVAudioPlayerNode()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
var timePitch = AVAudioUnitTimePitch()
timePitch.pitch = 2000
let filePath: String = NSBundle.mainBundle().pathForResource("chimes", ofType: "wav")!
let fileURL: NSURL = NSURL(fileURLWithPath: filePath)!
let audioFile = AVAudioFile(forReading: fileURL, error: nil)
let audioFormat = audioFile.processingFormat
let audioFrameCount = UInt32(audioFile.length)
let audioFileBuffer = AVAudioPCMBuffer(PCMFormat: audioFormat, frameCapacity: audioFrameCount)
audioFile.readIntoBuffer(audioFileBuffer, …Run Code Online (Sandbox Code Playgroud)