小编ran*_*dom的帖子

这个iOS有什么样的讽刺错误?

我有一些代码用于排序日历日期,如下所示:

#if !(TARGET_IPHONE_SIMULATOR)
    NSString *formatString = [NSDateFormatter dateFormatFromTemplate:@"HH:mm dd MMM yyyy" options:0
                                                              locale:[NSLocale currentLocale]];
    [fmt setDateFormat:formatString];
#else
    [fmt setDateFormat:@"HH:mm dd MMM yyyy"];
#endif
Run Code Online (Sandbox Code Playgroud)

如果我在模拟器中运行它就可以了.如果我在设备上运行它,我会得到这个讽刺调试消息.

2012-09-19 22:40:13.972 APPNAME [4923:907]* - [__ NSCFCalendar组件:fromDate:]:日期不能为零

我的意思是,你觉得这个操作应该用零日期来表示什么?

目前已经避免了例外.

这个投诉会报告其中一些错误,然后进一步的违规行为只会默默地做任何随机的事情.这是此次发生的回溯(由于编译器优化,某些帧可能会丢失):

你必须嘲笑它​​,但我不确定我的dateFormatFromTemplate:代码有什么问题.任何帮助,将不胜感激.

运行Xcode V 4.5 btw


更新:

回溯:

0 CoreFoundation 0x39ff0e55 + 84
1 APPNAME 0x00040be1 - [MeetingsViewController dateAtBeginningOfDayForDate:] + 140

所以我猜我的dateAtBeginningOfDayForDate方法情况不好.看起来像这样:

/*
 Break down a given NSDate to its bare components for sorting
 */
- (NSDate *)dateAtBeginningOfDayForDate:(NSDate *)inputDate
{
    // Use the …
Run Code Online (Sandbox Code Playgroud)

debugging objective-c nsdateformatter ios

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

具有自签名证书的NSURLSession +服务器

我有一个生产的应用程序以及具有自签名证书的开发服务器.

我正在尝试测试NSURLSession和后台下载,但似乎无法过去- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler

当我使用时,NSURLConnection我可以使用以下方法绕过它:

- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {

    NSLog(@"canAuthenticateAgainstProtectionSpace %@", [protectionSpace authenticationMethod]);

    return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];
}

- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {

    NSLog(@"didReceiveAuthenticationChallenge %@ %zd", [[challenge protectionSpace] authenticationMethod], (ssize_t) [challenge previousFailureCount]);

    [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
}
Run Code Online (Sandbox Code Playgroud)

但我无法弄清楚如何使用NSURLSession> :(

这是我目前的(不起作用):

- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler {
    NSLog(@"NSURLSession did receive challenge.");

    completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
}
Run Code Online (Sandbox Code Playgroud)

我还尝试创建一个类别NSURLSession …

objective-c nsurlconnection ios ios7 nsurlsession

31
推荐指数
1
解决办法
3万
查看次数

将ISO 8601转换为NSDate

我有来自服务器的时间戳,如下所示:

2013-04-18T08:49:58.157+0000
Run Code Online (Sandbox Code Playgroud)

我试过去掉冒号,我已经尝试了所有这些:

将ISO 8601时间戳转换为NSDate:如何处理UTC时间偏移?

为什么NSDateFormatter无法解析ISO 8601格式的日期

这是我在的地方:

+ (NSDate *)dateUsingStringFromAPI:(NSString *)dateString {


    NSDateFormatter *dateFormatter;
    dateFormatter = [[NSDateFormatter alloc] init];

    //@"yyyy-MM-dd'T'HH:mm:ss'Z'" - doesn't work
    //@"yyyy-MM-dd'T'HH:mm:ssZZZ" - doesn't work
    //@"yyyy-MM-dd'T'HH:mm:sss" - doesn't work 

    [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
    [dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];

    // NSDateFormatter does not like ISO 8601 so strip the milliseconds and timezone
    dateString = [dateString substringWithRange:NSMakeRange(0, [dateString length]-5)];

    return [dateFormatter dateFromString:dateString];
}
Run Code Online (Sandbox Code Playgroud)

我最大的问题之一是,我上面的日期格式是否真的是ISO 8601?我从人们看到的所有例子都有不同的格式.有些人...157-0000,有些人最后没有任何东西.

formatting iso objective-c nsdate nsdateformatter

29
推荐指数
2
解决办法
1万
查看次数

如何停止enumerateObjectsUsingBlock Swift

如何停止块枚举?

    myArray.enumerateObjectsUsingBlock( { object, index, stop in
        //how do I stop the enumeration in here??
    })
Run Code Online (Sandbox Code Playgroud)

我知道你在obj-c中这样做:

    [myArray enumerateObjectsUsingBlock:^(id *myObject, NSUInteger idx, BOOL *stop) {
        *stop = YES;
    }];
Run Code Online (Sandbox Code Playgroud)

enumeration block objective-c nsarray swift

28
推荐指数
4
解决办法
8930
查看次数

获取缩略图的视频快照

我正在使用Apple提供的AVCam代码从iPhone相机录制视频.

录制视频后,会将其保存到照片库中.

然后加载一个新视图,这里我需要有一个视频的图像缩略图.

我有一条视频路径:

file://localhost/private/var/mobile/Applications/ED45DEFC-ABF9-4A5E-9102-21680CC1448E/tmp/output.mov
Run Code Online (Sandbox Code Playgroud)

我似乎无法想象如何将视频的第一帧用作缩略图.

任何帮助将非常感谢,谢谢你的时间.


编辑

我最终使用了这个,我不确定为什么它将图像侧面返回?

- (UIImage*)loadImage {

    AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:vidURL options:nil];
    AVAssetImageGenerator *generate = [[AVAssetImageGenerator alloc] initWithAsset:asset];
    NSError *err = NULL;
    CMTime time = CMTimeMake(1, 60);
    CGImageRef imgRef = [generate copyCGImageAtTime:time actualTime:NULL error:&err];
    NSLog(@"err==%@, imageRef==%@", err, imgRef);

    return [[UIImage alloc] initWithCGImage:imgRef];

}
Run Code Online (Sandbox Code Playgroud)

video xcode avfoundation ios

26
推荐指数
1
解决办法
1万
查看次数

在iOS上快速模糊

我在尝试模糊iOS应用中的部分屏幕时遇到了麻烦.请参阅图片以更好地了解我正在尝试做什么.

BlurBox

只有"BlurBox"的内容需要模糊,但其余内容可以清晰.因此,如果您正在查看表格视图,则只有BlurBox下方的内容会模糊(即使您滚动).其余的看起来很清楚.

我的第一个方法是调用UIGraphicsGetImageFromCurrentImageContext()每个.01s来将BlurBox下的所有图层组合成一个图像.然后模糊该图像并将其显示在所有内容上.

我尝试模糊的方法是:

https://github.com/tomsoft1/StackBluriOS

https://github.com/coryleach/UIImageAdjust

https://github.com/esilverberg/ios-image-filters

https://github.com/cmkilger/CKImageAdditions

[layer setRasterizationScale:0.25];
[layer setShouldRasterize:YES];
Run Code Online (Sandbox Code Playgroud)

以及一些自定义尝试.我也看过Apple的GLImageProcessing,但我认为对于我在这里尝试做的事情来说有点矫枉过正.

问题是,他们都是 减缓.该应用程序不在应用程序商店上,所以我愿意使用任何私有/未记录的框架.

我有一种很远的想法是覆盖drawRect我使用的所有组件(UITableViewCells,UITableView等)的方法,并在运行中独立模糊它们.然而,这需要一些时间,这听起来像是一个可行的选择吗?


更新:

我尝试使用CIFilters如下:

CIImage *inputImage = [[CIImage alloc] initWithImage:[self screenshot]];

CIFilter *blurFilter = [CIFilter filterWithName:@"CIGaussianBlur"];
[blurFilter setDefaults];
[blurFilter setValue: inputImage forKey: @"inputImage"];
[blurFilter setValue: [NSNumber numberWithFloat:10.0f]
                           forKey:@"inputRadius"];


CIImage *outputImage = [blurFilter valueForKey: @"outputImage"];

CIContext *context = [CIContext contextWithOptions:nil];

self.bluredImageView.image = [UIImage imageWithCGImage:[context createCGImage:outputImage fromRect:outputImage.extent]];
Run Code Online (Sandbox Code Playgroud)

这确实有效,但速度非常慢.:(

我发现只有当我传入从磁盘加载的图像时,某些实现才会模糊.如果我传入我使用UIGraphicsGetImageFromCurrentImageContext()它创建的UIImage 不起作用.关于为什么会这样的任何想法?


更新:

我试过如下的Patel建议:

CALayer *backgroundLayer …
Run Code Online (Sandbox Code Playgroud)

image core-graphics image-processing objective-c uiimageview

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

iPhone 5上的UIView高度不对

我正在使用我的应用程序迁移我的应用程序UIPickerView.在viewDidLoad方法中,我创建了选择器,并将它的y原点设置self.view.frame.size.height为不在屏幕上.然后我会在需要时将其移动.

在iPhone 5 self.view.frame.size.height仍然返回480但UIView正确填充屏幕.

我甚至尝试过使用CGRectGetHeight(self.view.bounds)它可能会返回不同的东西......没有骰子.关于为什么会发生这种情况的任何想法.

xcode objective-c uiview cgrect

13
推荐指数
2
解决办法
1万
查看次数

如何导出Firebase分析数据

我正在尝试确定是否可以将所有Firebase Analytics数据导出到Excel电子表格,类似于您使用Google Analytics执行此操作的方式.从我能找到的唯一方法来做到这一点是与BigQuery链接然后做一些SQL语句来构建表和导出.

对我们来说不幸的是,这不起作用(由于客户预算和能力).有没有其他方法可以导出我丢失的数据?

analytics firebase firebase-analytics

13
推荐指数
1
解决办法
1万
查看次数

UINavigationBar,按钮作为标题.

我做了一些挖掘,似乎无法获得任何有用的东西.

我想要做的是非常基本的,但我不确定它们是否是:

1.一种更简单的方法

或者,如果苹果公司给它一个"不,不"

我有一个通过UINavigationController控制的视图(很明显来自这篇文章的标题),并且它有一个对象/视图.

该视图已经内容相当拥挤.没有真正的拥挤,但没有更多的空间舒适地适应事物.

用户需要能够使用不同的启动次数(1-5)对此对象进行评级.

我会看到这种情况发生的理想方式是在UINavigationBar标题位置设置5个星形按钮(当然是图像)(居中).

所以看起来像这样:

___________________________________
|                                 |
| Back      * * * * *     Action  |
|_________________________________|
|                                 |
|         view down here          |
|                                 |
Run Code Online (Sandbox Code Playgroud)

任何意见都将非常感谢,并一如既往地感谢您的时间!

xcode objective-c uinavigationbar uinavigationcontroller ios

10
推荐指数
1
解决办法
5308
查看次数

Google Maps API,我需要购买吗?

我目前正在创建一个应用程序(iPhone/iPad/Android),它使用地图来显示租赁公司提供的房屋.该应用程序在所有商店免费.

我已阅读条款并了解本条款:

Use of the Google Geocoding API is subject to a query limit of 2,500 geolocation requests per day. (User of Google Maps API for Business may perform up to 100,000 requests per day.) This limit is enforced to prevent abuse and/or repurposing of the Geocoding API, and this limit may be changed in the future without notice. Additionally, we enforce a request rate limit to prevent abuse of the service. If you exceed the 24-hour limit …

xcode android google-maps ios

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