小编e2l*_*l3n的帖子

通知中心缺少iOS应用程序

问题:该应用程序未出现在通知中心,并且在安装完成后无法立即接收推送通知,并且应用程序通过注册推送通知registerForRemoteNotificationTypes:.

细节:

  • 设备重启后,应用程序通常会出现在通知中心,之后一切正常.
  • 有时,应用程序会在安装和注册APN之后立即显示在通知中心(我仍然无法确认这一点,但我认为我偶然发现了这种情况).
  • registerForRemoteNotificationTypes每次用户登录时,应用程序都会调用该方法,每次用户分别使用位掩码(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)和UIRemoteNotificationTypeNone.
  • enabledRemoteNotificationTypes 返回正确的值.
  • 最初我unregisterForRemoteNotifications在注销时使用了这个方法,但我把它更改为registerForRemoteNotificationTypes:UIRemoteNotificationTypeNone由于怀疑这可能导致问题.
  • 在开发和adhoc构建中都会出现此问题,而与应用程序是否通过xcode或itunes安装无关.

任何想法和建议将不胜感激.谢谢!

iphone push-notification apple-push-notifications ios

13
推荐指数
1
解决办法
5万
查看次数

如何计算CATextLayer字符串的边界框?

乍一看,我的问题看起来很简单,但似乎我真的找不到解决方案.它是这样的:我想计算CATextLayer字符串的边界框.这是我做的:

CATextLayer *textLayer = [CATextLayer layer];
textLayer.frame = CGRectMake(80, 0.0f, 36.0f, 18.0f);
textLayer.string = @"12";
textLayer.fontSize = [UIFont systemFontSize];
textLayer.foregroundColor = [UIColor whiteColor].CGColor;

NSLog(@"(width,height)=(%f,%f)",
[textLayer.string sizeWithFont:textLayer.font].width,
[textLayer.string sizeWithFont:textLayer.font].height);
Run Code Online (Sandbox Code Playgroud)

问题是输出总是:(宽度,高度)=(8.000000,0.000000)

iphone cocoa-touch objective-c calayer ios

7
推荐指数
2
解决办法
3851
查看次数