当我使用iOS11我的info.plist包含时,我在向用户请求位置权限时遇到问题
<key>NSLocationWhenInUseUsageDescription</key>
<string>When in use permissions</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>always permissions</string>
<key>NSLocationAlwaysAndWhenInUsageDescription</key>
<string>Always and in usage permissions</string>
Run Code Online (Sandbox Code Playgroud)
我有两张地图供客户使用,另一张供员工使用.对于员工,我需要知道他们的位置,即使应用程序没有运行或后台(他们能够在退出时关闭它)并请求使用权限
locationManager.requestAlwaysAuthorization()
对于客户,我只需要在应用程序正在使用时使用位置并请求使用权限
locationManager.requestWhenInUseAuthorization()
在iOS 11中,这仅在使用时请求权限,而不是始终在权限上.
在iOS 10中,它具有正确的行为.
我想要的行为如下:当他们是客户(未登录)时,它只询问何时使用权限.如果他们登录(员工),即使不使用它也会请求位置.
如果有人能够了解我所遗漏/做错的事情,我将不胜感激.
需要注意的是,如果我删除了NSLocationAlwaysUsageDescriptioniOS10和iOS11 的权限,则同样的问题是不要求总是允许.
多一点澄清.我已经实现了didChangeAuthorization委托函数,当用户允许来自警报的权限时,它会被调用,requestWhenInUseAuthorization()
但是当我requestWhenInUseAuthorization()在位置管理器上调用函数时,没有调用委托方法,就好像它从未接收到该调用并且没有显示警告对话框用户.
我在代码中的某个地方有一个僵尸对象,它在iOS 6.1上运行但在7中没有.
不幸的是,仪器不会与僵尸一起运行,它会弹出以下警告."僵尸只能在iOS 7或更高版本的设备上运行".
我真的不想下载旧版本的Xcode,因为互联网工作非常缓慢.
由于我的正常goto方法不可用,有什么一些提示/技巧可以找到这个僵尸的原因.
任何帮助将不胜感激.
如果今天的对象已经存在,我有一个查询Core Data的方法.
我的代码:
CoreDataHelper *cdh = [(MRMedSafeAppDelegate *) [[UIApplication sharedApplication] delegate] cdh];
NSManagedObjectContext *context = [cdh context];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"BMI" inManagedObjectContext:context];
[request setEntity:entity];
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear fromDate:[NSDate date]];
NSInteger day = [components day];
NSInteger month = [components month];
NSInteger year = [components year];
NSDateComponents *comps = [[NSDateComponents alloc] init];
[comps setDay:day];
[comps setMonth:month];
[comps setYear:year];
NSDate *today = [[NSCalendar currentCalendar] dateFromComponents:comps];
NSLog(@"patient: %@", patient);
NSPredicate …Run Code Online (Sandbox Code Playgroud) 我有一个奇怪的问题,使用presentViewController作为库的一部分.
使用该库的代码调用此方法.从调用presentViewController到运行完成块最多需要12秒.但并非所有时间通常几乎都是瞬间的.
但是,如果我触摸屏幕上的任何位置,当它"滞后"时,它会立即触发.
-(void) advancedMenuWithPresentingViewController
:(UIViewController *)presentingViewController
animated:(BOOL)animated
onClose:(void (^)(void))onClose
onPrint:(void (^)(NSString *, NSString *))onPrint{
AdvancedMenuViewController *amc = [[AdvancedMenuViewController alloc] init];
AdvancedMenuViewController * __weak weakAmc = amc;
[amc setOnClose:^(void)
{
[weakAmc dismissViewControllerAnimated:animated completion:^{
onClose();
}];
}];
[amc setOnPrint:onPrint];
//Time from here
[presentingViewController presentViewController:amc
animated:animated
completion:^{
//To here
}];
}
Run Code Online (Sandbox Code Playgroud)
调用viewDidLoad和viewWillAppear没有任何延迟,然后在调用viewDidAppear之前有一个很长的延迟(除非你触摸屏幕).
这些方法中没有任何内容会降低它的速度.因为它通常工作正常.
如果任何人能够对这个问题有所了解,我将非常感激,最令人困惑的部分是,如果你在触发advancedMenuWithPresentingViewController后与屏幕交互,它将立即发生.
ios ×4
objective-c ×2
core-data ×1
instruments ×1
ios11 ×1
iphone ×1
nspredicate ×1
swift ×1
xcode ×1
xcode5 ×1