- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我有一个 swift 项目,我想在其中检索设备的名称并显示在 UITableViewCell
中。
但是当我想调用 UIDevice.currentDevice()
时
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
编译器失败:
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
The following build commands failed:
CompileSwift normal arm64 "path to project folder"/custom_tableview_controller.swift
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (2 failures)
尴尬的事情是在任何其他文件中调用 UIDevice.currentDevice()
而不是我的 custom_tableview_controller.swift
文件正在运行。
附加信息:
- Xcode 6.4(6E35b)
- 调试
最佳答案
我创建它是为了在 Swift 框架中获取 UIDevice:
创建Obj-c Header.h并添加
#import <UIKit/UIKit.h>
/**
* Static Current Device
* @note Can't get UIDevice CurrentDevice in Swift, Hack with obj-c
*
* @return UIDevice
*/
static UIDevice* Device() { return [UIDevice currentDevice]; }
在您的目标框架 -> 构建阶段中:
在您的目标 Framework.h 中添加:
#import <BSStaticObjc.h>
现在在 Swift 调用方法中
Device()
关于ios - Swift UIDevice.currentDevice() 没有编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32312378/
我正在为 IOS 制作一个视频播放器,想要检查设备何时旋转,当我的代码将使视频播放器全屏显示时,但我收到以下错误 - 'Instance member 'currentDevice'不能在“viewC
[UIDevice currentDevice]可以带什么,比如uniqueIdentifier?谢谢! 最佳答案 因为这有点过时了,所以我只是给出一个最新的答案。 因为 Apple 认为从 iOS
[[UIDevice currentDevice] model]; 返回的所有可能值是什么?它不是 documented . 最佳答案 可能的值是iPod touch、iPhone、iPhone Si
我的应用程序使用UIDevice currentDevice identifierForVendor来帮助我识别设备。最近,我遇到了一种我无法理解的情况。我的一位客户的iPad的UIDevice cu
我正在尝试使用属性 UIDevice.currentDevice().orientation,所以我有如下内容 UIDevice.currentDevice().beginGeneratingDevi
我试图让我的应用程序(围绕 OpenFrameworks 构建)中的相机自动对焦。看完this SO post我通读了 AV Foundation Programming Guide关于如何设置对焦模
当我为设备方向更改添加通知时,如下所示: NSNotificationCenter.defaultCenter().addObserver(self, selector: Select
我有一个 swift 项目,我想在其中检索设备的名称并显示在 UITableViewCell 中。 但是当我想调用 UIDevice.currentDevice() 时 override func t
[[UIDevice currentDevice] systemName]; 的可能值是什么?在docs来自 Apple,它没有给出任何可能产生的结果的例子,但我能从中得到的只是 iPhone OS,
我有一种产品有两种不同的应用。并且这两个应用程序都为同一设备提供了不同的标识符(您会假设苹果会将其关联到您的开发者帐户,以便您可以在您的应用程序中重复使用这些信息),但我想知道他们能给我什么两个应用程
所以,since Apple is now rejecting apps that access UDID , 在我们公司当前的项目中,我们需要消除所有调用此属性的 API: [[UIDevice c
我们注意到,在 MonoTouch 中使用 UIDevice.CurrentDevice.Name 时,UTF8 字符无法正确显示。 如果您使用某些特殊字符(例如按住 iPad 键盘上的撇号键),它会
我正在使用 x-code 6.3 工具来分析我的应用程序,但我不明白为什么这一行会导致内存泄漏: + (NSString*)IDFV { NSUUID* device_id = [[UIDev
这个问题在这里已经有了答案: The advertisingIdentifier and identifierForVendor return "00000000-0000-0000-0000-00
在我看来这在 iOS9 中不再有效。这是根据我的 SO 研究强制改变方向的实际方法。它现在卡住了我的 SpriteKit 游戏。 只有我一个人吗?如果不是,有人知道替代方案吗? 编辑:Portrait
我正在学习在单元测试中使用 OCMocks,并且我了解基础知识。但是,我不确定如何模拟对类方法的调用。 我想要: [[UIDevice currentDevice] userInterfaceIdio
如题。调用 [[UIDevice currentDevice] BeginGeneratingDeviceOrientationNotifications] 无效。 DidRotateToInterf
这是一个最重要的观察,因为我似乎找到了解决方法...... 当下面的代码位于已推送到 UINavigationController 堆栈的 Controller 中时,它无法工作。在这种情况下,[UI
我在调用 MonoTouch.UIKit.UIDevice.CurrentDevice.SystemVersion 时发生崩溃。它发生在模拟器上。我无法轻松重现它...我已将调试器跟踪放在下面。 使用
我在我的所有应用程序中都使用了[[UIDevice currentDevice] uniqueIdentifier],Apple 不再允许使用uniqueIdentifier。我需要一些东西来替换 u
我是一名优秀的程序员,十分优秀!