我尝试了几种方法来获取文件大小,但始终为零.
let path = NSBundle.mainBundle().pathForResource("movie", ofType: "mov")
let attr = NSFileManager.defaultManager().attributesOfFileSystemForPath(path!, error: nil)
if let attr = attr {
let size: AnyObject? = attr[NSFileSize]
println("File size = \(size)")
}
Run Code Online (Sandbox Code Playgroud)
我进入日志: File size = nil
IBOutlets发生了一些奇怪的事情.

在代码中我尝试访问这些属性,但它们是nil.码:
class CustomKeyboard: UIView {
@IBOutlet var aButt: UIButton!
@IBOutlet var oButt: UIButton!
class func keyboard() -> UIView {
let nib = UINib(nibName: "CustomKeyboard", bundle: nil)
return nib.instantiateWithOwner(self, options: nil).first as UIView
}
override init() {
super.init()
commonInit()
}
override init(frame: CGRect) {
super.init(frame: frame)
commonInit()
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
commonInit()
}
// MARK: - Private
private func commonInit() {
println(aButt)
// aButt is nil
aButt = self.viewWithTag(1) as UIButton
println(aButt)
// aButt …Run Code Online (Sandbox Code Playgroud) 完整的操作系统更新后,我无法将新版本的应用程序上传到appstore.尝试安装java版本9+和8+,不起作用.在Application Loader中,我得到了这个日志:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.apple.transporter.launcher.Application.start(Application.java:206)
at com.apple.transporter.launcher.Application.main(Application.java:519)
Caused by: java.lang.IllegalStateException: could not find needed OSGiFramework
at com.apple.transporter.osgi.BootstrapHelper.setupClassLoader(BootstrapHelper.java:120)
at com.apple.transporter.osgi.FelixOSGiBootstrapper.bootstrap(FelixOSGiBootstrapper.java:9)
Run Code Online (Sandbox Code Playgroud)
XCode 9.2,java版"1.8.0_151"
我有一个支持横向和纵向模式的应用程序.我需要像在iOS 6上一样的行为状态栏.最简单的方法是什么?
我已经尝试过Stack Overflow问题iOS 7状态栏中的解决方案回到iOS 6风格?,但它不起作用.我的子视图取决于视图大小,我的视图无法正确拉伸.我不想更新我的XIB文件; 我只想添加一些有助于我的东西.我不知道它是什么(黑客或祈祷).
Apple 演示了带有 3d 姿态估计的控制 3d 机器人。一切都连接在一起,就像魔法一样运作。没有SceneKit用。
https://developer.apple.com/documentation/arkit/content_anchors/capturing_body_motion_in_3d
我正在尝试手动控制同一个机器人SceneKit。想出一个不方便的方法:
let rightHand = skeleton?.childNode(withName: "right_hand_joint", recursively: true)
rightHand?.rotation = SCNVector4(0, 1, 0, .pi / 2.0)
rightHand?.parent?.rotation = SCNVector4(0, 1, 0, .pi / 2.0)
Run Code Online (Sandbox Code Playgroud)
有没有其他方法可以设置关节的位置,它会自动计算骨架的角度?我发现的所有其他示例都从.dae文件中加载了一些动画。
我开始学习android开发,我无法弄清楚如何将库添加到项目中.我使用Android Studio.我创建了新项目,项目结构中没有项目设置.
升级到之后Xcode 7.0,我将所有项目转换为Swift 2.0.但是我无法更新Carthage库.我收到这个警告:
无法在以下位置加载插件:/ Users/Alexandr/Library/Application Support/Developer/Shared/Xcode/Plug-ins/CocoaPodUI.xcplugin,跳过.失败的原因:*** - [__ NSPlaceholderDictionary initWithObjects:forKeys:count:]:尝试从对象[0]插入nil对象
还有几个错误:
Box/Box.swift:6:37:错误:'Printable'已重命名为'CustomStringConvertible'/Box/Box.swift:31:10:错误:'toString'已重命名为'String'Box/MutableBox.swift :8:51:错误:'Printable'已重命名为'CustomStringConvertible'Box/MutableBox.swift:25:10:错误:'toString'已重命名为'String'
我如何使用Swift 2.0框架版本?我的carthage文件看起来像:
github "Alamofire/Alamofire"
github "SwiftyJSON/SwiftyJSON"
github "ReactiveCocoa/ReactiveCocoa"
Run Code Online (Sandbox Code Playgroud)
在框架结束时添加"swift 2.0"无法正常工作.
~ xcodebuild -version
Xcode 7.0
Build version 7A220
~ carthage version
0.9.1
Run Code Online (Sandbox Code Playgroud)
接缝Alamofire并且SwiftyJSON已经支持Swift 2.0.因为ReactiveCocoa我们需要添加分支"swift2".
github "Alamofire/Alamofire"
github "SwiftyJSON/SwiftyJSON"
github "ReactiveCocoa/ReactiveCocoa" "swift2"
Run Code Online (Sandbox Code Playgroud) 我从这里下载Xcode 6.4 http://adcdownload.apple.com/Developer_Tools/Xcode_6.4/Xcode_6.4.dmg.然后选择以前的Xcode进行构建:
~ xcode-select -s "/Applications/Xcode_6.4.app/Contents/Developer"
但我无法编译库Carthage.我收到错误:
2015-09-18 19:13:58.057 xcodebuild[13961:788602] stream error: stream error at offset 8: unsupported version number ('1.04')
Run Code Online (Sandbox Code Playgroud)
在Xcode 7更新后的其他计算机上,同样的问题.库不能编译,但错误是不同的.
~ carthage version
0.8.0
Run Code Online (Sandbox Code Playgroud)
Cartfile:
github "Alamofire/Alamofire" "1.3.1"
Run Code Online (Sandbox Code Playgroud) 我正在写一个游戏,我需要编一根绳子.我用b2RopeJoint做了它,但在那里我没有找到机会让它变得有弹性.然后我寻找b2DistanceJoint,一切都很酷,有弹性,但我找不到能力设置一个限制只有最大距离(没有最小距离).
我该怎么做?
我正在尝试在Array中添加扩展方法,如下所示:
extension Array {
func contains(obj: T) -> Bool {
let filtered = self.filter {$0 == obj}
return filtered.count > 0
}
}
Run Code Online (Sandbox Code Playgroud)
但是self.filter {$0 == obj}不要工作.编译错误:
无法找到接受提供的参数的'=='的重载
为什么这段代码工作正常:
NSArray* arr = @[[CALayer layer], [CALayer layer]];
NSString *sumKeyPath = @"@sum.bounds.size.width";
CGFloat totalSize = [[arr valueForKeyPath:sumKeyPath] floatValue];
Run Code Online (Sandbox Code Playgroud)
但是这段代码给出了错误:
NSArray* arr = @[[UIImage imageNamed:@"img1"], [UIImage imageNamed:@"img2"]];
NSString *sumKeyPath = @"@sum.size.width";
CGFloat totalSize = [[arr valueForKeyPath:sumKeyPath] floatValue];
Run Code Online (Sandbox Code Playgroud)
错误: [NSConcreteValue valueForUndefinedKey:]:此类不是键值宽度的键值编码兼容.
NSArray* arr = @[[UIView new], [UIView new]];
NSString *sumKeyPath = @"@sum.bounds.size.width";
CGFloat totalSize = [[arr valueForKeyPath:sumKeyPath] floatValue];
Run Code Online (Sandbox Code Playgroud)
给出同样的错误