小编Tea*_*abs的帖子

如何在Swift中实例化NSViewController?

我目前的Swift代码

         var appBundle = NSBundle.mainBundle()
         let controller: ViewController = ViewController.init(nibName:        "ViewController", bundle: nil)
    self.window.contentView.addSubview(controller.view)
    controller.view.frame = self.window.contentView.bounds
Run Code Online (Sandbox Code Playgroud)

得到两个错误.一个是"类型名称后的预期成员名称或构造函数调用",另一个是"()不能转换为'ViewController'.作为参考,ViewController是一个继承自NSViewController的类.

这两个错误都发生在第二行代码上.提前致谢.

xcode objective-c nsviewcontroller ios swift

5
推荐指数
1
解决办法
6417
查看次数

UIView.beginAnimations上下文 - Swift

我在使用UIView(UIButton)在Swift中制作动画时遇到了麻烦.有人可以帮忙吗?这是我的代码.我主要遇到方法[UIView.beginAnimations]的问题.它需要我传入一个String和一个CMutableVoidPointer.这当前崩溃了.谢谢

    var newCenter:CGPoint = CGPointMake(playAgainButton.center.x, playAgainButton.center.y + 200)
    [UIView.beginAnimations(nil, context: nil)]
    [UIView.setAnimationDuration(1.0)]
    playAgainButton.center = newCenter
    [UIView.commitAnimations]
Run Code Online (Sandbox Code Playgroud)

xcode objective-c uiview ios swift

-3
推荐指数
1
解决办法
6193
查看次数

标签 统计

ios ×2

objective-c ×2

swift ×2

xcode ×2

nsviewcontroller ×1

uiview ×1