在NSDateFormatter文档中,
如果日期格式化程序使用相对日期格式,则在可能的情况下,它会使用短语(例如"今天"或"明天")替换其输出的日期组件 - 表示相对日期.
我使用以下代码:
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = [NSDateFormatter dateFormatFromTemplate:@"EEEE dMMMM',' hma"
options:0
locale:[NSLocale currentLocale]];
formatter.doesRelativeDateFormatting = YES;
NSLog(@"Date: %@", [formatter stringFromDate:[NSDate date]]);
Run Code Online (Sandbox Code Playgroud)
它记录Date:.
但在评论formatter.doesRelativeDateFormatting = YES;输出结果是正确的.
Date: Tuesday, 19 August 1:18 pm
我理解doesRelativeDateFormatting错了吗?
我在运行iOS 7的iPhone 4上的应用程序使用带有自定义的UITabBar barTintColor.如Apple文档中所述:https://developer.apple.com/library/ios/documentation/userexperience/conceptual/UIKitUICatalog/UITabBar.html
默认情况下,iOS 7上的标签栏是半透明的.此外,系统模糊应用于所有标签栏.这允许您的内容通过栏下方显示.
但是这种系统模糊在iPhone 4上不可见,并且UITabBar在设备上变得透明,如下所示:

我相信这可能会发生,因为iPhone 4中的GPU较弱,因此它必须回归透明而不是半透明.参考:http://arstechnica.com/apple/2013/09/new-lease-on-life-or-death-sentence-ios-7-on-the-iphone-4/
一个简单的解决方案就是UITabBar translucent有条不紊地制作适用于iPhone 4.但是我不想把这种依赖性放在设备类型上,我想知道我是否能以某种方式检测当GPU弱的时候iOS是否会回落到透明度?(从而使条件更合适)
我有一个带有associatedType. 我想typealias在协议扩展中为该类型提供一个默认值。这仅适用于从特定类继承的类。
protocol Foo: class {
associatedtype Bar
func fooFunction(bar: Bar)
}
Run Code Online (Sandbox Code Playgroud)
协议扩展:
extension Foo where Self: SomeClass {
typealias Bar = Int
func fooFunction(bar: Int) {
// Implementation
}
}
Run Code Online (Sandbox Code Playgroud)
编译器抱怨'Bar' is ambiguous for type lookup in this context. 我也无法在 swift 书中找到任何有用的东西。
我正在尝试在服务器上执行请求,该服务器响应Etag以进行缓存.我为它编写了以下代码,但这些调用的响应在大多数情况下是随机的,即有时响应状态代码为200,有时为304(预期).我在代码中做错了什么,或者AFNetworking有什么特别的东西我应该记住.
NSURL *url = [NSURL URLWithString:@"http://ia.media-imdb.com/images/M/MV5BNzI0NTY5NzQwMV5BMl5BanBnXkFtZTcwOTQyNTA5OA@@._V1._SY90_.jpg"];
NSMutableURLRequest *aRequest = [NSMutableURLRequest requestWithURL:url];
[aRequest setValue:@"\"61-smtLpBSL_SY90_#1\"" forHTTPHeaderField:@"If-None-Match"];
NSLog(@"headers: %@", aRequest.allHTTPHeaderFields);
AFImageRequestOperation *operation = [AFImageRequestOperation imageRequestOperationWithRequest:aRequest imageProcessingBlock:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
NSLog(@"%@ %d", response.allHeaderFields, response.statusCode);
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
NSLog(@"Request failed with error: %@", error);
}];
[operation start];
Run Code Online (Sandbox Code Playgroud) 根据iOS 上truecaller的行为,它会为其垃圾邮件联系人列表创建一个名为"已识别为垃圾邮件"的联系人.
在我的应用中导入联系人时,我想避免导入此联系人.
是否有任何(本地化安全)方式在iOS上执行此操作?
我需要在向后退按钮的引用UINavigationBar或UINavigationItem.下图中的Back按钮.
因此,我没有自定义按钮
navigationItem.backBarButtonItem
navigationItem.leftBarButtonItem
Run Code Online (Sandbox Code Playgroud)
这两者都是零.
有没有办法在没有自定义的情况下获得对按钮的引用?
参考:
更新:我的评论可能有助于理解为什么我不想自定义后退按钮.:)
一个问题是在我的Xcode项目中产生警告.这在2.2.3版本中得到了解决(补丁版本更改,即2.2.2中存在问题).
以前我的Podfile使用:
pod 'AFNetworking', '~> 2.0'
Run Code Online (Sandbox Code Playgroud)
这匹配所有版本2.0+但将匹配限制为小于3.0,即忽略了主要版本更改.
由于我需要的更改很重要(我不希望在编码时警告会延迟)并且仅在版本2.2.3+中可用我想要我的pod的规范
pod 'AFNetworking', '>= 2.2.3 & < 3.0'
Run Code Online (Sandbox Code Playgroud)
请注意,我仍然不希望主要版本碰撞一切,如果我只使用:
pod 'AFNetworking', '>= 2.2.3'
Run Code Online (Sandbox Code Playgroud)
因为这也会匹配3.0 ..
问题是Cocoapods不允许这样做并拒绝它解析自己的错误:
ArgumentError - Illformed requirement `">= 2.2.3 & < 3.0"`
Run Code Online (Sandbox Code Playgroud)
参考:
据我所知,在解析Podfile时,版本规范与正则表达式匹配:
quoted_operators = OPS.keys.map { |k| Regexp.quote k }.join '|'
PATTERN = /\A\s*(#{quoted_operators})?\s*(#{Version::VERSION_PATTERN})\s*\z/
Run Code Online (Sandbox Code Playgroud)
文件:cocoapods-core-0.32.1/lib/cocoapods-core/requirement.rb https://github.com/CocoaPods/Core/blob/master/lib/cocoapods-core/requirement.rb
此模式仅允许一个规范..
ios ×5
objective-c ×3
iphone ×2
swift ×2
addressbook ×1
afnetworking ×1
cocoapods ×1
import ×1
ios7 ×1