我在iOS5中使用ZBar进行扫描,效果很好.
现在更新到iOS6后,它无法正常工作.它显示以下错误.
ld: file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/mac4/Desktop/my desktop/My app/MyApp name 20:09:12 /MyApp name/ZBarSDK/libzbar.a for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
我身边出了什么问题?
我正在从服务器发送这个json响应,请求我的IOS 7应用程序.
{
"root": {
"success": "1",
"message": "Successfully retrieved data.",
"data": {
"records": [
{
"receipt_key": "xxxxxxxx",
"receipt_id": "xxxxxxxx",
"store_name": "xxxxxx",
"amount": "xxxx",
"date_purchase": "xxxxxxxx",
"is_processed": "x",
"created_on": "xxxxxxxx",
"modified_on": "xxxxxxxx",
"modified_on_millis": "xxxxxxxx",
"user_folder": "xxxxxxxx",
"category_id": "xxxxxxxx",
"is_deleted": "x",
"currency_id": "xxxxxxxx"
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
我使用以下代码解析上面的json到NSDictionary对象.
NSMutableDictionary *json=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];
Run Code Online (Sandbox Code Playgroud)
但是我在上面的代码中遇到了这个错误.
Error Domain = NSCocoaErrorDomain Code = 3840"操作无法完成.(Cocoa error 3840.)"(JSON文本不是以数组或对象开头,而是选项允许未设置片段.)UserInfo = 0x8a8a700 {NSDebugDescription = JSON text没有从数组或对象和选项开始,以允许未设置片段.}
我正在尝试UIView在收到按钮点击时执行此基本动画:
- (IBAction)buttonPress:(id)sender
{
self.sampleView.alpha = 0.0;
[UIView animateWithDuration:2.0
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionBeginFromCurrentState
animations:^{self.sampleView.alpha = 1.0;}
completion:NULL];
}
Run Code Online (Sandbox Code Playgroud)
在按钮之前单击视图是可见的,并且alpha值为1.0.当我发送按钮动作时,我希望视图在2秒内从alpha = 0.0淡入alpha = 1.0,但这不会发生.当我删除UIViewAnimationOptionBeginFromCurrentState动画工作正常.
看起来像UIViewAnimationOptionBeginFromCurrentState选项设置,没有设置alpha = 0.0并且跳过动画,因为它认为它已经是1.0.
我试图理解为什么会发生这种情况,因为Apple文档声明UIViewAnimationOptionBeginFromCurrentState如果另一个动画没有进行则没有效果:
" UIViewAnimationOptionBeginFromCurrentState
从与已在飞行中的动画相关联的当前设置开始动画.如果此键不存在,则允许在新动画开始之前完成任何飞行动画.如果另一个动画未在飞行中,则此键没有效果."
我正在尝试获取一组键,其中a中相应键的NSDictionary值为@ YES.
对于EG,:Starting Dictionary:
NSDictionary* dict = @{@"key1" : @YES, @"key2": @YES, @"key3": @NO, @"key4": @NO};
Run Code Online (Sandbox Code Playgroud)
期望的结果:
NSArray* array = @[@"key1", @"key2"];
Run Code Online (Sandbox Code Playgroud)
我尝试用NSPredicates和subpredicates做这个,但找不到一个做我想要的.我的"工作"但丑陋的解决方案是:
NSMutableArray* array = [[NSMutableArray alloc] initWithCapacity:0];
NSDictionary* dict = @{@"key1" : @YES, @"key2": @YES, @"key3": @NO, @"key4": @NO};
for (NSString* key in [dict allKeys]) {
if ([[dict objectForKey:key] isEqualToNumber:@YES])
[array addObject:key];
}
Run Code Online (Sandbox Code Playgroud)
什么是更好的方法,可能与NSPredicates?
objective-c ×3
ios ×2
ios6 ×2
cocoa-touch ×1
ios7 ×1
iphone ×1
nsarray ×1
nsdictionary ×1
nspredicate ×1
zbar-sdk ×1