小编Sea*_*lly的帖子

Xcode 7 UI测试:如何在代码中解除一系列系统警报

我正在使用新的Xcode 7 UI测试功能编写UI测试用例.在我的应用程序的某些时刻,我要求用户允许相机访问和推送通知.因此会出现两个iOS弹出窗口:"MyApp Would Like to Access the Camera"弹出窗口和"MyApp Would Like to Send You Notifications"弹出窗口.我希望我的测试可以解雇两个弹出窗口.

UI录制为我生成了以下代码:

[app.alerts[@"cameraAccessTitle"].collectionViews.buttons[@"OK"] tap];
Run Code Online (Sandbox Code Playgroud)

但是,[app.alerts[@"cameraAccessTitle"] exists]解析为false,上面的代码生成错误:Assertion Failure: UI Testing Failure - Failure getting refresh snapshot Error Domain=XCTestManagerErrorDomain Code=13 "Error copying attributes -25202".

那么在测试中解除一堆系统警报的最佳方法是什么?系统弹出窗口会中断我的应用程序流并立即使我的正常UI测试用例失败.事实上,任何有关如何绕过系统警报以便我可以恢复测试通常流程的建议都表示赞赏.

这个问题可能与这个SO帖子有关,也没有答案:Xcode7 | Xcode UI测试| 如何处理位置服务警报?

提前致谢.

objective-c ios xctest xcode7 xcode-ui-testing

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

iOS 8通知操作:访问"didFinishLaunchingWithOptions"中的keychain时"访问锁定钥匙串时尝试的项目"错误

我正在观察SecItemCopyMatching在锁定的手机上执行iOS 8推送通知时引发的设备控制台中的钥匙串错误.详细的重复步骤如下:

  1. 卸载所有以前版本的应用程序.在应用程序上构建应用程序的Appstore版本.强制退出应用程序.
  2. 增加内部版本号,并在设备上构建更新版本.这模拟了应用更新流程.强制退出应用程序(在现实生活中,应用程序可能因内存压力而被操作系统杀死.强制退出模拟此行为).
  3. 在手机锁定时向应用发送推送通知.
  4. 手机锁定后,向左滑动以查看操作按钮,然后按其中一个操作按钮.
  5. 应用程序被唤醒,didFinishLaunchingWithOptions被调用,试图访问钥匙串项目.运行时SecItemCopyMatching,Access to item attempted while keychain is locked设备控制台中会显示错误.

完整的错误日志如下所示.最后一行给出了应用程序特定的错误消息.

ReportCrash[32481] <Error>: task_set_exception_ports(B07, 400, D03, 0, 0) failed with error (4: (os/kern) invalid argument)
ReportCrash[32481] <Notice>: ReportCrash acting against PID 31423
diagnosticd[32258] <Error>: error evaluating process info - pid: 31423, punique: 131317
ReportCrash[32481] <Notice>: Formulating crash report for process cfprefsd[31423]
com.apple.xpc.launchd[1] (com.apple.cfprefsd.xpc.daemon[31423]) <Notice>: Service exited due to signal: Bus error: 10
My App[32480] <Error>: assertion failed: 12F70: …
Run Code Online (Sandbox Code Playgroud)

objective-c keychain apple-push-notifications ios ios8

25
推荐指数
1
解决办法
3813
查看次数

UITableView编辑模式 - 自定义减号删除按钮的颜色

当UITableView处于编辑模式时,有没有办法自定义减号删除按钮的颜色?设计师需要它是一个更深的红色,以符合我们的应用程序的配色方案.请注意,我在谈论左侧的圆圈减号删除图标,而不是右侧的删除确认按钮:

在此输入图像描述

SO帖子中,我发现如这一个是所有关于定制在右侧的删除确认按钮.

objective-c uitableview ios

8
推荐指数
1
解决办法
643
查看次数

iOS 8推送通知操作按钮 - 当app在后台时,handleActionWithIdentifier中的代码并不总是运行

我在iOS 8上的推送通知中添加了两个操作按钮:一个Accept按钮和一个Deny按钮.这两个按钮都不会打开应用程序,但根据按下的按钮,将会发出不同的服务器请求.这是我的设置:

+ (void)requestForPushNotificationToken {
    UIApplication *application = [UIApplication sharedApplication];
    // if ios 8 or greater
    if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
        UIMutableUserNotificationAction *acceptAction = [[UIMutableUserNotificationAction alloc] init];
        [acceptAction setActivationMode:UIUserNotificationActivationModeBackground];
        [acceptAction setTitle:@"Accept"];
        [acceptAction setIdentifier:@"ACCEPT_ACTION"];
        [acceptAction setDestructive:NO];
        [acceptAction setAuthenticationRequired:NO];

        UIMutableUserNotificationAction *denyAction = [[UIMutableUserNotificationAction alloc] init];
        [denyAction setActivationMode:UIUserNotificationActivationModeBackground];
        [denyAction setTitle:@"Deny"];
        [denyAction setIdentifier:@"DENY_ACTION"];
        [denyAction setDestructive:NO];
        [denyAction setAuthenticationRequired:NO];

        UIMutableUserNotificationCategory *actionCategory = [[UIMutableUserNotificationCategory alloc] init];
        [actionCategory setIdentifier:@"ACTIONABLE"];
        [actionCategory setActions:@[acceptAction, denyAction]
                        forContext:UIUserNotificationActionContextDefault];

        NSSet *categories = [NSSet setWithObject:actionCategory];

        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound …
Run Code Online (Sandbox Code Playgroud)

objective-c apple-push-notifications ios ios8

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

iOS钥匙串:更新kSecAttrAccessible时,SecItemUpdate返回-50(paramErr)

我需要更新钥匙串条目的kSecAttrAccessible。我不需要更新实际数据,只需更新可访问性属性即可。

首先,我尝试找到该项目以确保我的查询字典良好:

sanityCheck = SecItemCopyMatching((__bridge CFDictionaryRef)(queryPrivateKey), (void *)&privateKeyRef);
Run Code Online (Sandbox Code Playgroud)

此行成功找到我要查找的商品(返回码为0)。

然后,使用相同的查询更新kSecAttrAccessible属性:

if (sanityCheck == noErr && privateKeyRef != nil) {
    // found it, update accessibility
    NSMutableDictionary *updatedAttributes = [[NSMutableDictionary alloc] init];
    updatedAttributes[(__bridge id)kSecAttrAccessible] = (__bridge id)kSecAttrAccessibleAlways;
    OSStatus updateItemStatus = SecItemUpdate((__bridge CFDictionaryRef)queryPrivateKey, (__bridge CFDictionaryRef)updatedAttributes);
}
Run Code Online (Sandbox Code Playgroud)

此时,updateItemStatus为-50(paramErr)。

我看了一下这个线程:是否可以更新钥匙串项目的kSecAttrAccessible值? 但是我的问题是不同的。即使我将kSecValueData添加到我的代码,它也会返回-50updatedAttributes。此外,文档还指出,我们仅需要为iOS 4和更早版本添加kSecValueData。我支持iOS 7及更高版本,所以这不是我的问题。

有人可以指出我在这里想念的东西吗?非常感谢。

keychain security-framework ios

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

当收到多个 Android 通知时,只有最新通知上的操作按钮起作用

我的 Android 通知有操作按钮。当我连续发送两个通知时,点击第一个通知上的操作按钮不会产生任何效果(操作处理程序代码不会执行),但点击最新通知上的操作按钮会按预期工作。

private void displayNotification(Context context, ChallengeInformation extras) {
    /* build the notification */
    NotificationCompat.Builder mBuilder =
            new NotificationCompat.Builder(context)
                    .setSmallIcon(R.drawable.status_bar_icon)
                    .setContentTitle(context.getString(R.string.push_notification_title))
                    .setStyle(new NotificationCompat.BigTextStyle()
                            .bigText(getChallengeContextString(extras)))
                    .setContentText(context.getString(R.string.push_notification_description))
                    .setAutoCancel(false) // We don't want to cancel when the user clicks
                    .setPriority(NotificationCompat.PRIORITY_MAX)
                    .setColor(context.getResources().getColor(R.color.notification))
                    .setLocalOnly(true) // we handle notifications on Wear separately
                    .setDefaults(DEFAULTS);

    /* set the target of the notification */
    PendingIntent challenge =
            getChallengePendingIntent(context, extras);
    mBuilder.setContentIntent(challenge);

    addNotificationActions(mBuilder, context, extras);

    challengeTracker.notifyChallenge(extras, context, mBuilder.build());
}

private void addNotificationActions(NotificationCompat.Builder builder, Context context,
                                    ChallengeInformation extras) {
    //add buttons …
Run Code Online (Sandbox Code Playgroud)

notifications android push-notification android-notifications google-cloud-messaging

4
推荐指数
1
解决办法
676
查看次数

升级到Xcode 5.0引入了数百个相同的警告"在6.0之前的iOS版本上的字母间距调整"

我以前在Xcode 4.0中有一个项目.它运行时没有任何警告或错误.我刚把它移到了Xcode 5.0.在摆脱了大量错误后,我现在留下了数百个相同的警告:"属性不可用.在6.0之前的iOS版本上调整字母间距." 警告出现在我的xib文件中.任何人都知道导致警告的原因以及如何摆脱它们?

提前致谢!

ios7 xcode5

0
推荐指数
1
解决办法
712
查看次数