Posts

Post marked as solved
1 Replies
1.4k Views
I have a UI test for my app which should take a screenshot of all the relevant screens. It works nicely for iPhone in portrait but on iPad, where I rotate the device to landscape (using XCUIDevice.shared.orientation = .landscapeLeft), the screenshots are only partially visible. The screenshot is taken in portrait even though the device is currently running in landscape, resulting in the lower section being black and the right part being cut off. The interesting thing I've noticed: all automatic screenshots taken by Xcode while running individual test steps are created correctly but the one I create myself using the snippet below is cut-off. Am I doing something wrong? func takeScreenShot(_ element: XCUIElement, name: String = "Screenshot") {     let screenshot = element.screenshot()     let attachment = XCTAttachment(screenshot: screenshot)     attachment.name = name     attachment.lifetime = .keepAlways     add(attachment) } in setUp: override func setUp() { 		let app = XCUIApplication()  	app.launch()     if UIDevice.current.userInterfaceIdiom == .pad {         XCUIDevice.shared.orientation = .landscapeLeft     } 		// ... more unrelated stuff } And later while running a test: XCTContext.runActivity(named: "Image of the day is shown") { (_) in     let dismissButton = app.buttons["dismissImageOfTheDay"].firstMatch     XCTAssert(dismissButton.waitForExistence(timeout: 4.0), "The dismiss button exists")     takeScreenShot(app, name: "00_ImageOfTheDay")     dismissButton.tap() }
Posted
by pi80223.
Last updated
.
Post not yet marked as solved
0 Replies
542 Views
Is there a NSUserActivity which can be observed using .onContinueUserActivitywhen my media playback app is brought back to the foreground due to the user tapping on the artwork of the remote control? (Yes, I'm using SwiftUI and the iOS 14 app lifecycle.) I want to ensure that I refresh my UI to show the corresponding media item in full screen. But I don't want that to happen if the user simply is coming back to my app after browsing or writing an email. Is there a solution? Perhaps some AppDelegate stuff?
Posted
by pi80223.
Last updated
.
Post not yet marked as solved
2 Replies
1.1k Views
I was following the SwiftUI tutorial series and finished with the watchOS app (https://developer.apple.com/tutorials/swiftui/creating-a-watchos-app). The problem I see now, is that the custom NotificationView provided in the NotificationController.swift source is never properly shown with the circle image, as illustrated in the tutorial step "Create a Custom Notification Interface" step 9 (=final step).It seems, as if the data of the push notification is not used at all and therefore an empty NotificationView is instantiated. (=title is "Unknown Landmark", no image displayed).Therefore I've added console logs to all the functions and have found that didReceive is never called. override func didReceive(_ notification: UNNotification)There is an deprecated didReceive function which includes a completion handler, which is getting called and delivers notification data... override func didReceive(_ notification: UNNotification, withCompletion completionHandler: @escaping (WKUserNotificationInterfaceType) -> Void)But as soon as I implement this method myself, the other functions which generate the NotificationView (body) or provide lifecycle information (willActivate,didDeactivate) are not called at anymore...Is there anybody who has successfully implemented a custom watchOS notification view using SwiftUI?I somehow doubt that the tutorial is properly working anywhere...
Posted
by pi80223.
Last updated
.