如何删除UISearchControlleriOS 11下的行?
我添加了UISearchController使用此代码:
navigationItem.searchController = searchController
Run Code Online (Sandbox Code Playgroud)
但这样做之后,它下面有一条奇怪的线:
任何关于如何去除线条或至少选择其颜色的建议将不胜感激。
我有一个小问题,我找不到解决方案!
我的代码是(这只是一个示例代码,但我的原始代码执行类似的操作):
float x = [@"2.45" floatValue];
for(int i=0; i<100; i++)
x += 0.22;
NSLog(@"%f", x);
Run Code Online (Sandbox Code Playgroud)
输出是52.450001而不是52.450000!
我不知道因为这种情况发生了!
谢谢你的帮助!
〜〜解决
谢谢大家!是的,我用双重型解决了!
我有一个MKAnnotation名为的对象数组arrAnnotations.我想从与CLLocation名为"newLocation" 的对象中存储的坐标相同的坐标中选择一个注释.
我正在尝试使用a NSPredicate,但它不起作用.
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(SELF.coordinate == %f)", newLocation.coordinate];
NSArray* filteredArray = [arrAnnotations filteredArrayUsingPredicate:predicate];
[self.mapView selectAnnotation:[filteredArray objectAtIndex:0] animated:YES];
Run Code Online (Sandbox Code Playgroud)
filteredArray始终包含零个对象.
我也试过以下,但也无效
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(coordinate == %f)", newLocation.coordinate];
Run Code Online (Sandbox Code Playgroud)
和
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(coordinate > 0)"];
Run Code Online (Sandbox Code Playgroud)
和
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(coordinate.latitude == %f)", newLocation.coordinate.latitude];
Run Code Online (Sandbox Code Playgroud)
最后两个崩溃了应用程序,第三个崩溃了NSInvalidArgumentExceptionfor [NSConcreteValue compare:]和第四个,因为latitude它不符合键值编码(我认为这是因为坐标只是一个c-struct而不是一个NSObject?).
我该如何使用它NSPredicate?任何人都可以给我一个链接到一个文件,显示Predicates如何在幕后工作?我不明白他们实际做了什么,尽管我已阅读并理解Apple的Predicate Programming Guide的大部分内容.正在使用for ... in构造中搜索带有谓词的大型数组比使用谓词循环更有效吗?如果是/否,为什么?
cocoa ×2
comparison ×1
ios11 ×1
nspredicate ×1
objective-c ×1
performance ×1
predicate ×1
swift ×1