我正在开发适用于iOS 6.1和7的iPhone应用程序(使用Xcode 5).我对iPad发布图像有疑问.
在iPad 7.0和7.0.2上,启动图像没有显示(在6.1工作!):我在应用程序加载时出现黑屏.
我没有遇到iPhone 6.1和7.0.2的这个问题,虽然我设置了iPad和iPad视网膜(横向和纵向)所需的所有启动图像,并且我使用资产目录.
我错过了什么?
我正在创建一个NSMutableRequest:
self.req = [NSMutableURLRequest requestWithURL:myURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10.0];
Run Code Online (Sandbox Code Playgroud)
超时设置为10秒,因为我不希望用户等待太长时间来获得反馈.之后我创建了一个NSURLSessionDataTask:
NSURLSessionDataTask *task = [self.session dataTaskWithRequest:self.req completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSHTTPURLResponse * httpResp = (NSHTTPURLResponse *)response;
if (error) {
// this is where I get the timeout
}
else if (httpResp.statusCode < 200 || httpResp.statusCode >= 300) {
// handling error and giving feedback
}
else {
NSError *serializationError = nil;
NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&serializationError];
}
[task resume];
}
Run Code Online (Sandbox Code Playgroud)
问题是服务器进入Gateway Timeout并且需要花费很多时间.我收到超时错误并向用户提供反馈,但由于超时错误,以下所有API调用都以相同方式失败.阻止它的唯一方法是杀死应用程序并重新开始.在超时错误后,我应该做些什么来终止任务或连接?如果我没有设置超时并且我等到从服务器收到错误代码,则以下所有调用都能正常工作(但是用户会等待很多!).
我试图取消任务:
NSURLSessionDataTask …Run Code Online (Sandbox Code Playgroud) 我有这个字符串
23/Gennaio/2014
我需要另一个字符串
23/01/2014
我尝试使用joda.time:
DateTimeFormatter format = DateTimeFormat.forPattern("dd/MMM/yyyy").withLocale(Locale.ITALY);
DateTime instance = format.parseDateTime("23/Gennaio/2014");
String month_number = String.valueOf(instance.getMonthOfYear());
Run Code Online (Sandbox Code Playgroud)
但是我得到了这个例外:
01-06 13:31:55.341:E/AndroidRuntime(1116):java.lang.IllegalArgumentException:格式无效:"23/Gennaio/2014"
我错过了什么?