我试图获取联系人的出生数据但是如果用户没有选择年份或者联系人来自Facebook和年份或者自己的数据是隐藏的那么它给了我年份的"1604"值你可以看到我意思是在图像中.


通常,我使用以下代码来识别设备的iOS版本.
if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0)
Run Code Online (Sandbox Code Playgroud)
以类似的方式,我试图找到设备的金属支持.使用A7(或更好)GPU和iOS 8.0的Apple设备支持Metal.
这是我希望我的代码工作的方式:
if (MetalSupported == true) {
// metal programming
} else {
// opengles2 programming
}
Run Code Online (Sandbox Code Playgroud)
如何获取布尔变量的值MetalSupported?
我看过WWDC视频与搜索和深层链接的改进有关.在"无缝链接到您的应用程序"视频中,演讲者讨论了如何设置应用程序和相关的Web服务器以支持"通用链接".我不完全清楚的是Universal Links是否适用于iOS 8或仅适用于iOS 9.当他谈到签署apple-app-site-association文件时,他表示只需要签名才能使用iOS 8.为了清楚起见,Universal Links是否适用于iOS 8,现在???
这是我关心的用例.
关联的应用程序打开并通过URL处理要处理的URL
func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]!) -> Void) -> Bool
Run Code Online (Sandbox Code Playgroud)特别:
谢谢!
我有一个UIView按钮,并且需要在视图添加到按钮时将焦点设置在按钮上self.view,但我不知道为什么按钮在添加视图时不会聚焦!
- (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context withAnimationCoordinator: (UIFocusAnimationCoordinator *)coordinator {
if (context.nextFocusedView == backButton) {
[UIView animateWithDuration:1 delay:0 usingSpringWithDamping:.40 initialSpringVelocity:.60 options:UIViewAnimationOptionAllowUserInteraction animations:^ {
context.nextFocusedView.transform = CGAffineTransformMakeScale(1.5, 1.5);
context.nextFocusedView.layer.shadowOffset = CGSizeMake(0, 10);
context.nextFocusedView.layer.shadowOpacity = 1;
context.nextFocusedView.layer.shadowRadius = 15;
context.nextFocusedView.layer.shadowColor = [UIColor redColor].CGColor;
context.nextFocusedView.layer.shadowOpacity = 1;
} completion:nil];
}
}
Run Code Online (Sandbox Code Playgroud)
我也尝试了其他属性:
- (void)openView {
[backButton preferredFocusedView];
[backButton canBecomeFocused];
[backButton setNeedsFocusUpdate];
[self.view addSubView:customView];
}
- (UIView *)preferredFocusedView {
return [backButton preferredFocusedView];
}
Run Code Online (Sandbox Code Playgroud)
但这些都没有奏效!
我正在尝试使用大约6个图像的数组将场景的背景内容设置为天空盒效果.
我已经按照正确的顺序创建了图像数组,我知道我需要使用它
+ (instancetype) materialPropertyWithContents:(id)contents
Run Code Online (Sandbox Code Playgroud)
但是我正在努力弄清楚我是如何以及在何处使用该类方法来返回包含多维数据集映射的属性.
一直在寻找Scenekit上的灯光,虽然我现在可以应用一个灯光节点来点亮我正在寻找一种从物体内发光的方法.
举一个例子,想象一下霓虹灯发光,或者在其他物体上投射光线的灯泡.
任何想法如何实现这一目标?
非常感谢.
Objective-C API使用类方法进行大量的对象构造:
+ (NSDate *)date;
+ (NSURL *)urlWithString:(NSString *)string;
+ (instancetype)layerWithSession:(AVCaptureSession *)session
Run Code Online (Sandbox Code Playgroud)
有时我甚至将这些出现在旧的Swift教程中作为类方法出现,但是当我尝试调用它们时,我会遇到如下编译器错误:
date()不可用,使用对象构造NSDate()
urlWithString()不可用,使用对象构造NSURL(string:)
layerWithSession()不可用,使用对象构造AVCaptureVideoPreviewLayer(session:)
(我convenience init(URL url: NSURL)在文档中看到了声明,在Xcode中为SDK类生成了Swift接口,但它们与这些有什么关系?)
当我在我自己的ObjC代码中声明类方法时,甚至会发生这种情况,例如单例模式:
@interface MyManager: NSObject
+ (instancetype)manager;
@end
Run Code Online (Sandbox Code Playgroud)
当我尝试从Swift中使用它们时,我得到了同样的错误:
let manager = MyManager.manager()
// error: 'manager()' is unavailable, use object construction 'MyManager()'
Run Code Online (Sandbox Code Playgroud)
是什么赋予了?我该如何解决这些错误?
我正在使用Apples Photos Framework将PHAssetCollections加载到我的应用程序中.我总是得到智能收藏的英文名称.例如,我得到'收藏'而不是'收藏家'(瑞典语).我认为localizedTitle属性将返回模拟器或iPhone运行的语言.(在具有瑞典语和地区的iPhone上运行).
有人遇到过这种情况么?示例代码:
NSArray *collectionsFetchResults;
NSMutableArray *localizedTitles = [[NSMutableArray alloc] init];
PHFetchResult *smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum
subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];
PHFetchResult *syncedAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum
subtype:PHAssetCollectionSubtypeAlbumSyncedAlbum options:nil];
PHFetchResult *userCollections = [PHCollectionList fetchTopLevelUserCollectionsWithOptions:nil];
// Add each PHFetchResult to the array
collectionsFetchResults = @[smartAlbums, userCollections, syncedAlbums];
for (int i = 0; i < collectionsFetchResults.count; i ++) {
PHFetchResult *fetchResult = collectionsFetchResults[i];
for (int x = 0; x < fetchResult.count; x ++) {
PHCollection *collection = fetchResult[x];
localizedTitles[x] = collection.localizedTitle;
NSLog(@"%@", collection.localizedTitle); //<= Always …Run Code Online (Sandbox Code Playgroud) 我正在通过PHImageManager从相机胶卷加载图像,但返回的图像不是视网膜分辨率.我是否必须自己提供2倍和3倍的倍增器,或者我有什么问题吗?
这是我的代码:
class ReviewableImageView: UIImageView {
...unrelated code
imageRequestOptions = PHImageRequestOptions()
imageRequestOptions.deliveryMode = .HighQualityFormat
imageRequestOptions.resizeMode = .Exact
...unrelated code
self.contentMode = .ScaleAspectFit
self.backgroundColor = UIColor.clearColor()
self.userInteractionEnabled = true
... unrelated code
func reloadImage(){
let imageManager = PHCachingImageManager()//PHImageManager()
imageManager.requestImageForAsset(self.imageAsset,
targetSize: self.frame.size,
contentMode: .AspectFit,
options: imageRequestOptions,
resultHandler: { (image: UIImage!, info: [NSObject : AnyObject]!) in
self.image = image
})
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个UITabBarController有4个项目标签.其中之一是AvCaptureVideoPreviewLayer(是条形码扫描仪).我想要做的是仅为AVCaptureVideoPreviewLayer(如iOS相机应用程序)禁用自动item bar旋转,而不是与屏幕一起旋转的自动旋转.这有点困难,因为我认为UITabBarConrtoller不允许你轻松禁用旋转.
我的相机视图的代码是:
import UIKit
import AVFoundation
class ScannerViewController: UIViewController,
// MARK: Properties
/// Manages the data flow from the capture stage through our input devices.
var captureSession: AVCaptureSession!
/// Dispays the data as captured from our input device.
var previewLayer: AVCaptureVideoPreviewLayer!
// MARK: Methods
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.blackColor()
self.captureSession = AVCaptureSession()
// This object represents a physical capture device and the properties associated with that …Run Code Online (Sandbox Code Playgroud)