小编Can*_*ğlu的帖子

didRegisterForRemoteNotificationsWithDeviceToken从未在特定设备上调用过

首先,我在iPhone 6 Plus/iOS 8.1上,我已经在这里尝试了一切:为什么没有调用RegisterForRemoteNotificationsWithDeviceToken

仍然无济于事.总结一下:

  • 我已经检查了我的捆绑标识符与配置文件/开发门户中的标识符匹配
  • 我已经创建了一个新的开发推送APNS证书
  • 我已经创建了一个新的开发证书
  • 我为该开发证书创建了一个新的配置文件
  • 我已经下载了证书和配置文件,显然,双击它们进行安装
  • 我已经验证了Developer Portal上的一切正确:所有证书和配置文件都有效,推送已启用并配置了我的新APNS证书
  • 我已将我的新APNS证书上传到Parse(这一步与此无关,但无论如何)因为我正在使用Parse作为后端
  • 我确保在Xcode上使用正确的证书/配置文件对进行协同设置
  • 我已经检查了通知设置以防我的应用程序不允许接收推送,它不存在
  • 我已经尝试手动设置日期到明天,并尝试重新安装该应用程序
  • 我已从设备中删除了该应用
  • 我已从设备中删除了任何相关的配置文件
  • 我多次重启我的设备

application:didFinishLaunchingWithOptions:我打电话:

if([application respondsToSelector:@selector(registerUserNotificationSettings:)]){
        //iOS 8+
        [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
    }else{
        //pre-iOS 8
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
         (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
    }
Run Code Online (Sandbox Code Playgroud)

application:didRegisterUserNotificationSettings:我打电话:

[application registerForRemoteNotifications];
Run Code Online (Sandbox Code Playgroud)

我用断点检查了它,它被调用了.我还实现了两种方法:

application:didRegisterForRemoteNotificationsWithDeviceToken:

application:didFailToRegisterForRemoteNotificationsWithError:

但是,它们都没有被称为.不是错误,没有.控制台也没有错误.(我今天早些时候遇到了有关权利的问题,但创建了新的证书/配置文件解决了这个问题)

可能是什么问题?

更新:这是一些东西.在application:didRegisterUserNotificationSettings:我检查的通知设置,这里是我得到了什么:

(lldb) po notificationSettings
<UIUserNotificationSettings: 0x170031cc0; types: (none);>
Run Code Online (Sandbox Code Playgroud)

更新2:我再次检查了通知,发现现在我的应用程序被添加到设置中的通知中,它已启用,具有权限.但是,仍然没有调用处理程序.类型是没有的.我99%肯定这与问题有关.

更新3:我已经在另一台设备上测试过(iPod touch,iOS 8.1),我没有遇到任何问题.它立即application:didRegisterForRemoteNotificationsWithDeviceToken:使用其令牌调用该方法.问题是我的iPhone特有的.

xcode push-notification apple-push-notifications ios provisioning-profile

17
推荐指数
2
解决办法
1万
查看次数

OAuth错误:此IP无法为该应用程序发出请求

我刚刚开始This IP can't make requests for that application.使用我的应用程序随机出错.我的服务器的IP地址在我的应用程序设置的白名单中,并且它运行正常,但我随机开始出现此错误.我检查了服务器的IP(即使我已经知道它是静态的),我已经删除了白名单中的所有条目,但似乎都没有.很奇怪,我可以从我家测试完全相同的代码,它的工作原理!可能是问题的原因是什么?即使几分钟前也没有发生这种情况,但现在我的服务器出错了.

谢谢,可以.

更新:我似乎也无法删除白名单.我去了app高级设置,IP再次出现了.我删除了它们并保存了,它说已经保存了但是当我向下滚动时,IP仍然存在.我认为这是Facebook的一个严重错误.但是[当前不可编辑的]列表无论如何都包含我的服务器的IP.

oauth facebook-graph-api facebook-oauth facebook-opengraph

15
推荐指数
3
解决办法
2万
查看次数

UIView内的UIButton不响应触摸事件

我已经在自定义UIView中放置了一个UIButton并且该按钮没有接收到任何触摸事件(它没有进入突出显示的状态,所以我的问题在于无法连接内部处理程序中的触摸).我已经尝试将它放入Interface Builder中的XIB中,并尝试以编程方式将UIButton单独添加到UIView中,两者都没有运气.我的所有视图都在UIScrollView中,所以我首先虽然UIScrollView可能会阻止它们,所以我还以编程方式添加了一个按钮,就像我将自定义视图添加到UIScrollView中一样,按钮工作,消除了UIScrollView的可能性是原因.My View的hiearchy是这样的:

SS

按钮位于图像视图上方,前面层没有完全占据我的按钮,所以我没有理由不与按钮进行物理交互.在我的自定义视图的代码端,我正在创建我的视图:

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        UIView *sub = [[[NSBundle mainBundle] loadNibNamed:@"ProfileView" owner:self options:nil] objectAtIndex:0];
        [self addSubview:sub];
        [sub setUserInteractionEnabled:YES];
        [self setUserInteractionEnabled:YES];
        CALayer *layer = sub.layer;
        layer.masksToBounds = YES;
        layer.borderWidth = 5.0;
        layer.borderColor = [UIColor whiteColor].CGColor;
        layer.cornerRadius = 30.0;
        /*layer.shadowOffset = CGSizeZero;
        layer.shadowRadius = 20.0;
        layer.shadowColor = [[UIColor blackColor] CGColor];
        layer.shadowOpacity = 0.8;
        */
    }
    return self;
}
Run Code Online (Sandbox Code Playgroud)

我已经尝试了所有的组合setUserInteractionsEnabled,并且没有运气.(是的,也将它们设置为在Interface Builder中检查).我还读了一个类似问题的另一个问题,我应该尝试重写'canBecomeFirstResponder'来返回'YES',我也做了.但问题仍然存在,我无法点击按钮.我没有给按钮任何特殊的属性,设置,它只是一个常规的.我在视图中的其他对象(下面的标签,按钮后面的图像视图等)正常工作没有问题.这可能有什么问题?

谢谢,

能够.

更新:以下是问题的快速复制:https: …

objective-c interface-builder uibutton xib uiview

14
推荐指数
2
解决办法
1万
查看次数

UISlider thumbTintColor doesn't change on iOS 7 (fine on iOS 6)

I have an app that runs perfectly on iOS 6. I've set a blinking effect to a UISlider's thumb this way:

-(void)startBlinkingSlider{
    isSliderBlinking = YES;
    isSliderTinted = NO;
    [self performSelector:@selector(toggleSliderColor) withObject:nil afterDelay:0.2];
}

-(void)toggleSliderColor{
    if(isSliderBlinking){
        if(isSliderTinted){
            self.effectAmountSlider.thumbTintColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1];
        }else{
            self.effectAmountSlider.thumbTintColor = [UIColor colorWithRed:255 green:0 blue:0 alpha:1];
        }
        isSliderTinted = !isSliderTinted;
        [self performSelector:@selector(toggleSliderColor) withObject:nil afterDelay:0.2];
    }
}

-(void)stopBlinkingSlider{
    isSliderBlinking = NO;
    isSliderTinted = NO;
    self.effectAmountSlider.thumbTintColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1];
}
Run Code Online (Sandbox Code Playgroud)

当我调用startBlinkingSlider我的滑块时,在iOS 6中开始闪烁红色.如果我在iOS …

objective-c uislider ios ios6 ios7

14
推荐指数
3
解决办法
1万
查看次数

UITableView insertRowsAtIndexPaths抛出__NSArrayM insertObject:atIndex:'object not not nil'错误

我试图动态地将一个项目插入到我的表视图中.我的应用程序有一个聊天部分,它在第0部分显示旧的(在初始化视图控制器之前从服务器加载)消息,并在第1部分显示刚发送/接收的消息(最初为零).当视图加载时,所有"旧"消息都被加载和显示,没有问题.当我尝试插入行时,问题就开始了.这是我在做的事情:

  • 我首先通过添加一个额外的项来更新我的表视图的数据源:( [newMessages addObject:newMessage];newMessage是我的自定义消息对象的实例,newMessages是我的数据源).我验证我的数据源现在有1个项目(在添加之前为0).
  • 然后我调用以下代码:

    [self.chatTableView beginUpdates];
    [self.chatTableView insertRowsAtIndexPaths:@[[NSIndexPath 
        indexPathForRow:newMessages.count - 1 inSection:1]] 
        withRowAnimation:UITableViewRowAnimationBottom];
    [self.chatTableView endUpdates];
    
    Run Code Online (Sandbox Code Playgroud)

我的应用程序在endUpdates方法崩溃,给我这个错误:*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'

我立即检查,如果newMessagenil或不是,它是不会 nil(并重新检查了我的数据源),这样的数据源是没有问题的.我认为这indexPathForRow:newMessages.count - 1可能是问题,并尝试了不同的值(计数-2,计数,计数+ 1),以防我错过了什么.在那些情况下,我收到了另一个错误:'NSInternalInconsistencyException', reason: 'attempt to insert row 1 into section 1, but there are only 1 rows in section 1 after the update'.错误说明了一切,所以问题也不indexPathForRow:newMessages.count - 1是.

我在-(UITableViewCell *)tableView:(UITableView *)tableView …

uitableview ios ios7

14
推荐指数
2
解决办法
4417
查看次数

查找"自动首选最大布局宽度"在8.0之前的iOS版本上不可用的原因

我知道这个警告的原因以及如何解决它:给标签一个优先宽度.

问题是,当我单击该警告时,我没有看到任何标签/视图/视图控制器被选中.故事板打开就是这样.在我的故事板中有许多具有许多视图的视图控制器.如何在不手动迭代所有视图控制器的情况下找出导致问题的标签?当我点击警告时,我希望它将我带到导致警告的视图,但它只是打开故事板.

xcode interface-builder xcode6 xcode6.1

14
推荐指数
2
解决办法
2万
查看次数

正常Parse函数上的主线程警告正在执行长时间运行的操作

首先,我知道这意味着什么.问题是我在无法转换为后台调用的标准调用上遇到此错误.我在应用开始时收到此错误:

[Parse enableLocalDatastore];

PFInstallation *currentInstallation = [PFInstallation currentInstallation];

我发现这些方法通过设置符号断点warnParseOperationOnMainThread并检查调用堆栈而导致问题.

我不能用异步的调用替换这些调用,据我所知,这些方法从主线程定期调用的.这是一个Parse bug,还是应该从后台线程调用所有这些方法?

ios parse-platform ios8 ios8.1

14
推荐指数
1
解决办法
1217
查看次数

Twitter logInWithCompletion或logInWithViewController没有做任何事情

我正在尝试登录用户的Twitter帐户.我已按照https://dev.twitter.com/twitterkit/ios/installation上的指南来整合Twitter.

但是,当我尝试登录时,没有任何反应:

[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession * _Nullable session, NSError * _Nullable error) {
      //not called
       if(session && !error){

       }else{

       }
 }];
Run Code Online (Sandbox Code Playgroud)

我也试过明确指定视图控制器:

[[Twitter sharedInstance] logInWithViewController:self completion:^(TWTRSession * _Nullable session, NSError * _Nullable error) {
   //again, not called.
   if(session && !error){

   }else{

   }
}];
Run Code Online (Sandbox Code Playgroud)

Twitter应用程序本身已登录并与我的帐户完美配合.

我究竟做错了什么?

更新:除了设备(具有Twitter应用程序和登录帐户)之外,我还尝试过模拟器(显然,它没有Twitter应用程序),在两种情况下都是一样的.

twitter ios twitterkit ios11

14
推荐指数
1
解决办法
662
查看次数

在UIKeyboardWillShowNotification /上,iOS键盘高度返回不正确

我正在尝试在键盘出现时滚动文本视图.我试图通过https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html关注Apple自己的教程.我使用autolayout而不是滚动视图和框架,但总体思路是相同的(订阅键盘通知,并相应地设置布局约束).但是,当我显示键盘时,文本视图和键盘之间存在间隙:(这是来自土耳其语键盘的屏幕截图,但是所有安装的键盘中都存在标有红色的相同间隙,包括自定义键盘).(iPhone 6 Plus的屏幕截图,但问题也出现在其他屏幕尺寸上)

在此输入图像描述

我已经看到在iOS8中无法获得键盘高度的正确值,我尝试过使用两者UIKeyboardFrameEndUserInfoKey,UIKeyboardFrameBeginUserInfoKey但它们都会产生相同的差距.我试过安装UIKeyboardWillShowNotificationUIKeyboardDidShowNotification,但仍,我得到了同样的差距.我认为差距与iOS 8上某些键盘上的建议有关,但是当建议不存在时,它不应该报告键盘大小和建议.

这是我的代码:

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self registerForKeyboardNotifications];
}

- (void)registerForKeyboardNotifications
{
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillBeShown:)
                                                 name:UIKeyboardWillShowNotification object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillBeHidden:)
                                                 name:UIKeyboardWillHideNotification object:nil];

}

// Called when the UIKeyboardDidShowNotification is sent.
- (void)keyboardWillBeShown:(NSNotification*)aNotification
{
    NSDictionary* info = [aNotification userInfo];
    CGRect kb = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];

    float height = kb.size.height;
    sendZoneBottomConstraint.constant = height;
    [UIView …
Run Code Online (Sandbox Code Playgroud)

ios ios8

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

如何在不关闭 macOS 中所有选项卡的情况下关闭 Vscode 窗口

我在许多项目之间切换,所有项目都有三重窗格和许多打开的选项卡。当我不处理项目时,我使用 GUI 通过普通的红色关闭窗口按钮关闭窗口。当我再次打开它时,我的所有选项卡都与我离开时一样。

如何使用键盘快捷键来完成此操作?Cmd+W 关闭当前选项卡(我不想要),Cmd+Q 完全退出 Vscode(我也不想要),关闭所有窗口。如何使用键盘关闭单个 Vscode 窗口,与使用鼠标点击关闭按钮相同,以便将来重新打开窗口时,所有选项卡都完好无损?

macos keyboard-shortcuts visual-studio-code

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