加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xcode – 从Playground运行的模拟器中闪烁的UIView

发布时间:2020-12-14 19:37:22 所属栏目:百科 来源:网络整理
导读:我正在运行一个游乐场,Xcode 6.3(6D543q).因此 Swift 1.2 Playground导入XCPlayground. 我正在创建一个UIView并调用XCPShowView()让它在模拟器中而不是在Playground中渲染. 我也以同样的方式呈现UIAlertView. UIAlertView正常显示. UIView在较大和较小的尺寸
我正在运行一个游乐场,Xcode 6.3(6D543q).因此 Swift 1.2

Playground导入XCPlayground.
我正在创建一个UIView并调用XCPShowView()让它在模拟器中而不是在Playground中渲染.
我也以同样的方式呈现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)

解决方法

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

从this post(他们的动画确实出现但闪烁,重叠)

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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读