小编Joh*_*ohn的帖子

PhoneGap是App开发的不错选择吗?

我是一个新的iOS开发人员,但目前对Android开发和Java一无所知.我将花时间学习开发Android版应用程序的工具.PhoneGap的跨平台能力听起来很强大,但我不确定是否有任何缺点.谁能告诉我使用PhoneGap的利弊?根据您的经验,您建议我使用原生Android或PhoneGap吗?在此先感谢您的任何建议.

android cordova

44
推荐指数
2
解决办法
4万
查看次数

通过[NSData dataWithContentsOfURL:...]读取文件后文件的AccessDate没有改变

我在文件系统中缓存一些用户信息.然后阅读使用

NSData *cachedMessagesData = [NSData dataWithContentsOfURL:fileDirectoryForUserInfoCache];
Run Code Online (Sandbox Code Playgroud)

我需要知道每个缓存文件的访问时间,但是,当我使用Property键检查访问时间时:

NSArray *filesInUserInfoCacheDirectory = [self.fileManager contentsOfDirectoryAtURL:self.cacheDirectoryForUserInfo includingPropertiesForKeys:[NSArray arrayWithObjects:@"NSURLCreationDateKey", @"NSURLContentAccessDateKey", nil] options:NSDirectoryEnumerationSkipsHiddenFiles error:nil];

NSDate *accessDate = [[[filesInUserInfoCacheDirectory lastObject] resourceValuesForKeys:[NSArray arrayWithObject:@"NSURLContentAccessDateKey"] error:nil] objectForKey:@"NSURLContentAccessDateKey"];
Run Code Online (Sandbox Code Playgroud)

我发现访问日期与文件创建日期相同.通过[NSData dataWithContentOfURL:...]读取文件不会更改文件的访问时间属性.

谁能告诉我为什么?有没有办法读取文件以更新访问时间?非常感谢提前.

nsurl

8
推荐指数
1
解决办法
850
查看次数

在iOS开发人员面板中创建iCloud标识符

我使用iCloud只是为了简单的键值存储.我在Xcode中配置了Entitlement.在沙盒模式下测试表明该值已成功保留.

但是,当我在iOS开发人员面板上查看我的配置文件的应用ID的设置时,我看到应用ID的iCloud状态是"可配置".它要我创建一个iCloud容器.

我的问题是:

1)开发人员面板上这样的iCloud容器的用途是什么?

2)是否有必要在开发人员面板上配置这样的iCloud容器以使iCloud在生产中可用?

3)如果问题2为是,开发者面板上的iCloud容器的标识符是否与Xcode中配置的Ubiquity容器标识符相同?开发人员面板要求我"输入iCloud容器的唯一标识符,从字符串'cloud'开始." 但是Xcode有$(TeamIdentifierPrefix)$(CFBundleIdentifier)作为标识符.

请帮忙.非常感谢.

xcode ios icloud

8
推荐指数
1
解决办法
1774
查看次数

WatchOS 2.0:WCSessionDelegate没有被调用(在Simulator中)

我正在版本7.0 beta 5上运行WatchOS 2.0。我正在通过iWatch App运行iOS。

如图所示,我设置了目标。

在此处输入图片说明

我的iOS的ViewController和WatchKitExtension的Interface Controller都已激活WCSession并被设置为委托。

if ([WCSession isSupported]) {
    WCSession *session = [WCSession defaultSession];
    session.delegate = self;
    [session activateSession];
    NSLog(@"iOS App WCSession is supported");
}
Run Code Online (Sandbox Code Playgroud)

然后我尝试将userInfo从Watch发送到iOS:

NSDictionary *userInfo = [[NSDictionary alloc]initWithObjectsAndKeys:@"testingURL", @"outputURL", nil];
        [[WCSession defaultSession] transferUserInfo:userInfo];
Run Code Online (Sandbox Code Playgroud)

但是我的ViewController的委托方法从来没有被调用过:

- (void)session:(WCSession *)session didReceiveUserInfo:(NSDictionary<NSString *,id> *)userInfo{

dispatch_async(dispatch_get_main_queue(), ^{
    NSLog(@"Received userInfo Transferr");
    NSLog(@"%@", userInfo);
    [self.label setText:@"Received"];
});
}
Run Code Online (Sandbox Code Playgroud)

我从模拟器中同时运行Watch App和iOS,方法是按以下方案中的Run(运行):

在此处输入图片说明

谁能告诉我我做错了什么?

objective-c ios apple-watch watchkit watchos-2

8
推荐指数
1
解决办法
2116
查看次数

NSURLSessionDownloadTask - 在didFinishDownloading之前读取下载的数据

我想,以取代NSURLConnectionNSURLSession,但我发现,NSURLSession我无法读取中间数据块像我一样在NSURLConnection与委托方法.

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
Run Code Online (Sandbox Code Playgroud)

我曾经在完成之前开始使用数据.我有点流.如何在NSURLSession完成之前访问下载的数据?

我注意到在完成之前有一个(NSURL *)location临时保存的数据位置NSURLSession,但我可以在完成之前获取此URL吗?

谢谢


根据Rob的建议尝试了这个:

NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:[NSOperationQueue mainQueue]];
NSURLSessionTask *task = [session dataTaskWithRequest:request];
[task resume];
Run Code Online (Sandbox Code Playgroud)

但是,只调用了didRecieveResponse

- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveResponse:(NSURLResponse *)response completionHandler:(void (^)(NSURLSessionResponseDisposition))completionHandler
Run Code Online (Sandbox Code Playgroud)

但didReceiveData没有被调用.

我试图将任务更改为downloadTask

NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate:self delegateQueue: [NSOperationQueue mainQueue]];
NSURLSessionDownloadTask * downloadTask =[defaultSession downloadTaskWithRequest:request];
[downloadTask resume];
Run Code Online (Sandbox Code Playgroud)

它适用于下载委托,但未调用数据委托(didReceiveData). …

ios nsurlsession nsurlsessiondownloadtask

7
推荐指数
1
解决办法
5311
查看次数

添加圆角到UIImageVIew和显示阴影效果

我有与此处链接相同的问题: 无法添加角半径和阴影

如果我把maskToBounds = YES,我得到圆角,但没有阴影如果我把maskToBounds = NO,我得到阴影,但没有圆角.

然后我按照上面那个链接中的指令设置了maskToBounds = NO,"而是设置了角半径并用圆角矩形设置了阴影的bezier路径.保持两者的半径相同".但是,我没有圆角,也没有任何阴影!(即没有阴影的方形图像)你可以帮我解决这个问题吗?我不知道我做错了什么.提前致谢.

self.userImageView.backgroundColor = [UIColor redColor]; 
self.userImageView.clipsToBounds = NO; 
self.userImageView.contentMode = UIViewContentModeCenter; 
self.userImageView.layer.masksToBounds = NO; 

self.userImageView.layer.borderWidth = 1; 
self.userImageView.layer.borderColor = [[UIColor grayColor] CGColor]; 

self.userImageView.layer.shadowOpacity = 1; 
self.userImageView.layer.shadowColor = [[UIColor blackColor] CGColor]; 
self.userImageView.layer.shadowRadius = 8.0f; 
self.userImageView.layer.shadowOffset = CGSizeMake(-3, 0);
self.userImageView.layer.shouldRasterize = YES; 

self.userImageView.layer.shadowPath = [[UIBezierPath bezierPathWithRoundedRect:[self.userImageView bounds] cornerRadius:10.0f] CGPath]; 

[self addSubview:self.userImageView]; 
Run Code Online (Sandbox Code Playgroud)

shadow calayer uiimageview

6
推荐指数
1
解决办法
7130
查看次数

核心数据与许多关系进行NSPredicate

我在CoreData中有两个名为User and Coupon的实体,它们处于多对多关系中.我想获取所有优惠券,除了user.userId = 1所拥有的优惠券,其中userId是NSString.

我用过: [NSPredicate predicateWithFormat:@"NOT(ANY couponOwners.userId = %@)", @"4"]; 作为fetchedResultsController的谓词

但不能过滤正确的结果.优惠券的couponOwners中的一个用户仍然具有userId = 4.

有人可以帮忙吗?我被困了很长一段时间.提前致谢.

core-data nspredicate nsfetchedresultscontroller

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

iOS Metal:Jaggies 抗锯齿

我试图用 renderEncoder 的 drawIndexedPrimitives 画一个半圆

[renderEncoder setVertexBuffer:self.vertexBuffer offset:0 atIndex:0];

[renderEncoder drawIndexedPrimitives:MTLPrimitiveTypeTriangleStrip
                              indexCount:self.indexCount
                               indexType:MTLIndexTypeUInt16
                             indexBuffer:self.indicesBuffer
                       indexBufferOffset:0];
Run Code Online (Sandbox Code Playgroud)

其中圆的 vertexBuffer 和 IndexBuffer 是通过计算创建的

int segments = 10;


float vertices02[ (segments +1)* (3+4)];
vertices02[0] = centerX;
vertices02[1] = centerY;
vertices02[2] = 0;

//3, 4, 5, 6 are RGBA
vertices02[3] = 1.0;
vertices02[4] = 0;
vertices02[5] = 0.0;
vertices02[6] = 1.0;    

uint16_t indices[(segments -1)*3];

for (int i = 1; i <= segments ; i++){
    float degree = (i -1) * (endDegree - startDegree)/ (segments -1) …
Run Code Online (Sandbox Code Playgroud)

opengl-es objective-c antialiasing ios metal

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

iOS - 全屏播放时的Youtube播放器控制器栏颜色

我在使用UIWebView的视图中嵌入了youtube.

NSString *html = [NSString stringWithFormat:@"<html> <body style=\"margin:0;\"><iframe class=\"youtube-player\" type=\"text/html\" width=\"%f\" height=\"%f\" src=\"http://www.youtube.com/embed/%@\" frameborder=\"0\" allowfullscreen></iframe></body></html>", self.view.bounds.size.width - kTitleLabelLeftIndent*2, kUIWebViewHeight, self.utubeId];

utubeWebView = [[UIWebView alloc]init];
[utubeWebView setAllowsInlineMediaPlayback:YES]; 
[utubeWebView loadHTMLString:html baseURL:nil];
Run Code Online (Sandbox Code Playgroud)

youtube网址已完全嵌入我的应用中.当我点击utudeWebView上的Play按钮时,它会显示如下全屏:

在此输入图像描述

顶部的红色控制器栏看起来不太好.有人可以告诉我如何更改该栏的颜色?

任何建议将不胜感激.提前致谢,

约翰

youtube ios ios6

4
推荐指数
1
解决办法
599
查看次数