iOS 10.3中的备用图标:避免出现图标更改通知对话框 [英] Alternate Icon in iOS 10.3: avoid notification dialog for icon change

查看:144
本文介绍了iOS 10.3中的备用图标:避免出现图标更改通知对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此新功能,当使用活动的应用程序进行更改时,将显示一个通知对话框,指出图标已被修改. 如何禁用此对话框?

I'm using this new feature and when the change is made with an active application, a notification dialog is displayed saying that icon has been modified. How to disable this dialog ?

推荐答案

如果您不介意使用私有方法,则可以尝试以下代码.

If you don't mind making use of private method, you can try the following code.

- (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 10.3中的备用图标:避免出现图标更改通知对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆