我正在运行一个操场,Xcode 6.3 (6D543q)。因此Swift 1.2
游乐场进口XCPlayground。我正在创建一个UIView,并调用XCPShowView(),让它在模拟器中而不是在游乐场中呈现。我也以同样的方式呈现一个UIAlertView。
UIAlertView显示为正常。UIView大小介于大小之间,每秒大约5次,不规律。我试过调整大小,以满足屏幕的界限,但没有运气。
下面的代码..。
// Playground - noun: a place where people can play
import UIKit
import Foundation
import XCPlayground
XCPlayground.XCPSetExecutionShouldContinueIndefinitely(continueIndefinitely: true)
@objc class alertHandler: NSObject, UIAlertViewDelegate {
func alertView(alertView: UIAlertView, clickedButtonAtIndex buttonIndex: Int) {
if buttonIndex > 0 {
// View things....
let redRectangleFrame = CGRect(x: 0, y: 0, width: 200, height: 200)
let redRectangle = UIView(frame: redRectangleFrame)
redRectangle.backgroundColor = UIColor.redColor()
redRectangle.setTranslatesAutoresizingMaskIntoConstraints(false)
XCPShowView("Red Rectangle", redRectangle)
// Alert view things...
let recevingAlertView = alertView
let text = alertView.textFieldAtIndex(0)?.text
println("\(text!)")
println("Button \(buttonIndex)")
}
}
}
let anAlertHandler = alertHandler()
let status = "Hey there!"
let message = "Do you have a moment to talk about our Lord and Saviour, Cthulhu?"
let cancel = "Sounds wierd"
let ok = "Oooh! Yes"
let alert = UIAlertView(title: status,
message: message,
delegate: anAlertHandler,
cancelButtonTitle: cancel,
otherButtonTitles: ok)
alert.alertViewStyle = UIAlertViewStyle.PlainTextInput
alert.show()
XCPShowView("Alert", alert)发布于 2015-05-24 20:27:27
注意到一些本地闪烁与一些测试操场模拟器的例子(你的例子是崩溃的版本6.3.2 (6D2105))
来自这个职位 (他们的动画确实出现了,但闪烁,重叠)
在操场上,UIKit也有一些限制和退让。主要的限制是自动布局在操场中使用时有一些问题。除了增加编译时间外,某些约束还会导致运行时异常。希望将来对Xcode的更新能够解决这个问题。另一个缺点是使用XCPlayground时操场的性能。当Xcode使用运行在游乐场后面的iOS模拟器时,可能会出现延迟。
https://stackoverflow.com/questions/29110255
复制相似问题