在从操场上运行的模拟器中闪烁UIView

时间:2023-01-23 21:23:27

I'm running a playground, Xcode 6.3 (6D543q). Therefore Swift 1.2

我正在运行一个游乐场,Xcode 6.3(6D543q)。因此Swift 1.2

The Playground imports XCPlayground. I'm creating a UIView and calling XCPShowView() to have it render in the Simulator instead of in the Playground. I'm also presenting a UIAlertView the same way.

Playground导入XCPlayground。我正在创建一个UIView并调用XCPShowView()让它在模拟器中而不是在Playground中呈现。我也以同样的方式呈现UIAlertView。

The UIAlertView appears as normal. The UIView flickers between a larger and smaller size about 5 times a second, reasonable irregularly. I've tried resizing it to meet the bounds of the screen but no luck.

UIAlertView正常显示。 UIView在较大和较小的尺寸之间闪烁大约每秒5次,合理的不规则。我已经尝试调整它以满足屏幕的界限,但没有运气。

Code below....

// 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)

1 个解决方案

#1


1  

Noticed some flicker locally with a few test playground simulator examples (your example was crashing for me Version 6.3.2 (6D2105))

通过一些测试游乐场模拟器示例在本地注意到一些闪烁(您的示例为我崩溃版本6.3.2(6D2105))

From this post (their animation did show up but was flickering, and overlapping)

从这篇文章(他们的动画确实出现,但闪烁,重叠)

There are some limitations and draw backs to UIKit in Playgrounds. The primary limitation is that Auto Layout has some issues when used in Playgrounds. Some constraints will cause runtime exceptions in addition to increased compile times. Hopefully future updates to Xcode will resolve this. Another draw back is the performance of Playgrounds when using XCPlayground. There can be delays as Xcode works with the iOS Simulator running behind the Playground.

在Playgrounds中,UIKit有一些限制和缺点。主要限制是在Playgrounds中使用Auto Layout时会出现一些问题。除了增加编译时间之外,某些约束还会导致运行时异常。希望未来对Xcode的更新将解决这个问题。另一个缺点是使用XCPlayground时Playgrounds的性能。由于Xcode适用于在Playground后面运行的iOS模拟器,因此可能存在延迟。

#1


1  

Noticed some flicker locally with a few test playground simulator examples (your example was crashing for me Version 6.3.2 (6D2105))

通过一些测试游乐场模拟器示例在本地注意到一些闪烁(您的示例为我崩溃版本6.3.2(6D2105))

From this post (their animation did show up but was flickering, and overlapping)

从这篇文章(他们的动画确实出现,但闪烁,重叠)

There are some limitations and draw backs to UIKit in Playgrounds. The primary limitation is that Auto Layout has some issues when used in Playgrounds. Some constraints will cause runtime exceptions in addition to increased compile times. Hopefully future updates to Xcode will resolve this. Another draw back is the performance of Playgrounds when using XCPlayground. There can be delays as Xcode works with the iOS Simulator running behind the Playground.

在Playgrounds中,UIKit有一些限制和缺点。主要限制是在Playgrounds中使用Auto Layout时会出现一些问题。除了增加编译时间之外,某些约束还会导致运行时异常。希望未来对Xcode的更新将解决这个问题。另一个缺点是使用XCPlayground时Playgrounds的性能。由于Xcode适用于在Playground后面运行的iOS模拟器,因此可能存在延迟。