我正在使用这个新功能,当对事件应用程序进行更改时,会显示一个通知对话框,说明图标已被修改。 如何禁用此对话框?
最佳答案
如果你不介意使用私有(private)方法,你可以试试下面的代码。
- (void)lc_setAlternateIconName:(NSString*)iconName
{
//anti apple private method call analyse
if ([[UIApplication sharedApplication] respondsToSelector:@selector(supportsAlternateIcons)] &&
[[UIApplication sharedApplication] supportsAlternateIcons])
{
NSMutableString *selectorString = [[NSMutableString alloc] initWithCapacity:40];
[selectorString appendString:@"_setAlternate"];
[selectorString appendString:@"IconName:"];
[selectorString appendString:@"completionHandler:"];
SEL selector = NSSelectorFromString(selectorString);
IMP imp = [[UIApplication sharedApplication] methodForSelector:selector];
void (*func)(id, SEL, id, id) = (void *)imp;
if (func)
{
func([UIApplication sharedApplication], selector, iconName, ^(NSError * _Nullable error) {});
}
}
}
关于ios - iOS 10.3 中的备用图标 : avoid notification dialog for icon change,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43356570/