Tôi đang trải qua dao động tác chuyển động bằng cách sử dụng đoạn mã saubất ngờ dao động hiệu quả chuyển động trong tvOS
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication,
didFinishLaunchingWithOptions launchOptions:
[NSObject: AnyObject]?) -> Bool {
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window!.rootViewController = ExampleController()
self.window!.makeKeyAndVisible()
return true
}
}
class ExampleController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let redView = UIView(frame: CGRect(x: 200, y: 200,
width: 800, height: 500))
redView.backgroundColor = UIColor.redColor().colorWithAlphaComponent(0.5)
self.view.addSubview(redView)
let effect = UIInterpolatingMotionEffect(keyPath: "center.x",
type: .TiltAlongHorizontalAxis)
effect.minimumRelativeValue = -100
effect.maximumRelativeValue = 100
let effectGroup = UIMotionEffectGroup()
effectGroup.motionEffects = [effect]
redView.motionEffects = [effectGroup]
}
}
dẫn đến hành vi sau cả Simulator và trên Apple mới TV
Is có cách nào để tránh dao động?
Bạn đã thử trên một thiết bị thực? –
Tôi đã thử nghiệm mã và tôi có thể tái tạo hoàn toàn mã, tuy nhiên có vẻ như dao động đã có trong dữ liệu nghiêng nên tôi cho rằng nó được tạo khi chạm được chuyển thành độ nghiêng mô phỏng. Bạn nên thử nó trên thiết bị thực. – Sulthan
Có, cùng một hiệu ứng trên trình mô phỏng và trên Apple TV mới. – Andrei