小编har*_*eng的帖子

具有非有限位置的子层[inf inf]

我正在使用Objective-C编写的第三个CocoaPods库来截取UITextView的截图.对于iOS 8来说没关系,但是在我更改了iOS 9和Swift 2的语法后,它会抛出一个错误:

由于未捕获的异常'CALayerInvalidGeometry'而终止应用程序,原因:'子层具有非有限位置[inf inf]'

这是来自图书馆的代码:

- (UIImage *)screenshotForCroppingRect:(CGRect)croppingRect
{
    UIGraphicsBeginImageContextWithOptions(croppingRect.size, NO, [UIScreen mainScreen].scale);
    // Create a graphics context and translate it the view we want to crop so
    // that even in grabbing (0,0), that origin point now represents the actual
    // cropping origin desired:
    CGContextRef context = UIGraphicsGetCurrentContext();
    if (context == NULL) return nil;

    NSLog(@"hiii :%f" , croppingRect.size.width);

    CGContextTranslateCTM(context, -croppingRect.origin.x, -croppingRect.origin.y);

    [self layoutIfNeeded];
    [self.layer renderInContext:context];

    UIImage *screenshotImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return screenshotImage;
}
Run Code Online (Sandbox Code Playgroud)

问题是这一行:

[self.layer renderInContext:context];
Run Code Online (Sandbox Code Playgroud)

我意识到这是因为我试图拍摄包含UIScrollView的UIView的快照.如果我删除UIScrollView子视图,则错误消失. …

ios ios9 swift2

6
推荐指数
1
解决办法
1276
查看次数

Xcode UITest推送通知警报无法点击"允许"

有没有人有类似的情况?因此,应用程序打开,推送通知警报显示询问用户是否允许接收推送通知,测试单击"不允许",即使我有以下代码:

func testClickSystemAlert(){
        let app = XCUIApplication();
        XCUIApplication().alerts["“???” Would Like to Send You Notifications"].buttons["Allow"].tap()
    }
Run Code Online (Sandbox Code Playgroud)

这是print的输出(XCUIApplication().debugDescription);

Attributes: Application 0x60000016c540: {{0.0, 0.0}, {414.0, 736.0}}, label: '???'
Element subtree:
 ?Application 0x60000016c540: {{0.0, 0.0}, {414.0, 736.0}}, label: '???'
    Window 0x60000016bc40: Main Window, {{0.0, 0.0}, {414.0, 736.0}}
      Other 0x60000016c780: {{0.0, 0.0}, {414.0, 736.0}}
        Other 0x60000016c9c0: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
          ScrollView 0x60000016bf40: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
            Image 0x60000016c0c0: traits: 8589934596, {{0.0, 0.0}, {414.0, 736.0}}, identifier: '1'
          PageIndicator 0x600000163000: traits: 8589939200, {{132.0, …
Run Code Online (Sandbox Code Playgroud)

xcode ios xcode-ui-testing

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

XCTest UI 测试:在表格单元格中找不到 collectionView

有一个单元格包含一个集合视图。我已经使用

cell.accessibilityLabel = @"daren_shangjia_0001_add_new_photo_album";
Run Code Online (Sandbox Code Playgroud)

然后在 XCTest 中,我做

print(app.debugDescription);
Run Code Online (Sandbox Code Playgroud)

我没有看到我提供的辅助功能标签。

Element subtree:
 ?Application 0x608000367200: {{0.0, 0.0}, {414.0, 736.0}}, label: '???'
    Window 0x608000365e80: Main Window, {{0.0, 0.0}, {414.0, 736.0}}
      Other 0x608000365880: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
        Other 0x608000365b80: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
          Other 0x608000365700: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
            Other 0x608000364d40: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
              Other 0x608000364680: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
                Other 0x608000364740: traits: 8589934592, {{0.0, 0.0}, {414.0, 736.0}}
                  Other 0x608000364800: traits: 8589934592, {{0.0, …
Run Code Online (Sandbox Code Playgroud)

ios xctest

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

xcode UITests 检查测试是否在真实设备上运行

Xcode 版本 8.2 (8C38)

有没有办法检测 UITests 是否在真实设备上运行?

谢谢

xcode ios xcode-ui-testing

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

标签 统计

ios ×4

xcode ×2

xcode-ui-testing ×2

ios9 ×1

swift2 ×1

xctest ×1