Post

Replies

Boosts

Views

Activity

Reply to TipUIPopoverViewController disables all the views from presenting screen
Try setting the passthroughViews property on TipUIPopoverViewController's popoverPresentationController https://developer.apple.com/documentation/uikit/uipopoverpresentationcontroller/1622312-passthroughviews?language=objc Include the view controller's view that you are presenting in the array. tipUIPopoverViewController.popoverPresentationController.passthroughViews = @[self.view]; //then present it. Unfortunately I can't test this myself because even though TipUIPopoverViewController is a view controller subclass for whatever reason they decided not to include a header file that can be imported into Objective-C which is just bizarre.
Topic: UI Frameworks SubTopic: UIKit Tags:
Oct ’23
Reply to WKWebView -requestMediaPlaybackStateWithCompletionHandler: Reporting Incorrect Playback State?
Guess I'm going to have to try to do it with Javascript which is going to be difficult because media is often placed in iframes and communicating with user scripts across frame boundaries properly is kind of difficult. Also is there a way I can execute a script (from the native app) on all frames (without knowing of the existence of iframes)? Ideally something like -evaluateJavaScriptInAllFrames:inContentWorld:perFrameResponseHander:completionHandler: I can install a user script on all frames but when the native app wants to manipulate something in a subframe (say from a UIButton press), it doesn't seem like I can get ahold of a WKFrameInfo describing the iframe outside of the WKScriptMessageHandler callback. or...Is there a place in AVFoundation where I can pick up WKWebview playback events to avoid using javascript?
Topic: Safari & Web SubTopic: General Tags:
Oct ’23
Reply to Implement preferences menu entry in MacCatalyst
As you discovered UIAction just takes a block with no keyboard shortcut support and UIKeyCommand takes a selector and has no ability to set a target (UIKeyCommand just goes through the responder chain). For a top level action like "Show Settings" invoked from the menu bar it seems silly to me that the entire responder chain needs to be enumerated but that's how they decided to implement it in Mac Catalyst. A NSMenuItem in AppKit world can specify a target but for whatever reason they made the context menu/menu bar APIs a little weird in UIKit/Mac Catalyst. I believe the AppDelegate is supposed to participate in the responder chain but don't think it does on Mac Catalyst which is why the menu bar item isn't validating. Add your showPreferences method on UIApplication in a Swift extension or Objective-C category instead (UIApplication is in the responder chain). So long as nothing else in your responder chain implements a selector that collides with that name the UIApplication should always get it.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’23
Reply to WKWebView -requestMediaPlaybackStateWithCompletionHandler: Reporting Incorrect Playback State?
Breaking this down to a small sample project I get some strange results. Here's another example: The web view's configuration is set to: mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAll; I set the navigation delegate. Then I load a page like macrumors.com/2023/10/09/video-of-prototype-touchscreen-imac-g3/ After the page loads the -webView:didFinishNavigation: method is called. It is implemented like this: #pragma mark - Navigation Delegate -(void)webView:(WKWebView*)webView didFinishNavigation:(null_unspecified WKNavigation*)navigation { NSLog(@"-webView:didFinishNavigation:"); [self.webView requestMediaPlaybackStateWithCompletionHandler:^(WKMediaPlaybackState playbackState) { NSString *playbackStateString = webKitPlaybackStateToString(playbackState); NSLog(@"Playback State: %@",playbackStateString); }]; } And WKMediaPlaybackStatePlaying logs out. There is a YouTube video on the page but it is not playing. I'm not sure if this "playback state" is referring to an animated ad or something but from what I can tell the page doesn't have any video or audio playback. Am I misunderstanding the meaning of WKMediaPlaybackState?
Topic: Safari & Web SubTopic: General Tags:
Oct ’23
Reply to Code-level support ticket usage
I don't speak for Apple but from my experience I usually get credited back the ticket if they think the issue I'm reporting is a system bug initially (before talking to an Apple engineer) and they don't think there is a workaround they can advise. For example I opened a TSI recently and I got an email "No workaround is available" and I got my TSI credited back. Sometimes they won't necessarily think your issue relates to a system bug but then after talking to an engineer they may realize it is. In these cases I don't think they will refund your ticket once you start communication with an engineer (but I'm just speaking on my own experience I have no idea what their official policy is). They may suggest a workaround in these cases (but may not have one to offer either). Then everything ends with you filing a Bug Report and you wait but in my experience none of my bugs ever got fixed and I never hear from them again.
Oct ’23
Reply to Mac Catalyst Menu Bar/Toolbar Actions Not Validating Properly After Changing Active Windows
All they would need to do to fix this is to use a subclass on UIWindow for the scene that is created by NSUIViewToolbarItem (_UIViewHostingScene which is a subclass of UIWindowScene) and return NO from -canBecomeKeyWindow and -canBecomeFocused. Can confirm this by using Objective-C superpowers. Just swizzle -canBecomeKeyWindow and -canBecomeFocused and return NO for both these methods. -(BOOL)jjj_canBecomeKeyWindow { BOOL originalImp = [self jjj_canBecomeKeyWindow]; if ([self.windowScene isKindOfClass:NSClassFromString(@"_UIViewHostingScene")]) { //NEVER, EVER. return NO; } return originalImp; } -(BOOL)jjj_canBecomeFocused { BOOL originalImp = [self jjj_canBecomeFocused]; if ([self.windowScene isKindOfClass:NSClassFromString(@"_UIViewHostingScene")]) { //don't EVER! return NO; } return originalImp; } And then the responder chain/focus system doesn't break when you switch back to your app window.
Topic: UI Frameworks SubTopic: UIKit Tags:
Oct ’23
Reply to Mac Catalyst Menu Bar/Toolbar Actions Not Validating Properly After Changing Active Windows
After returning to this Catalyst project after some time away from it this issue is still occurring in Xcode 15 Sonoma. Basically the responder chain and the focus system breaks after making another app the frontmost app (menu bar owning) and then navigating back my app (making my app frontmost, menubar owning, etc). When I make my app frontmost again on Mac the focus system stops working. Tab key does nothing (it is expected to change focus) and many menu bar actions are not validating. @rttCanada Yes. It does seem like this could be related to NSUIViewToolbarItem. I have a NSUIViewToolbarItem subclass which wraps a UIButton subclass (in the system style). My subclass of UIButton just overrides canBecomeFocused and returns NO (because otherwise tabbing unexpectedly moved focus to this button in the toolbar which seemed wrong). //Wrapped in a NSUIViewToolbarItem subclass @implementation SystemStyledButtonInToolbarDontFocusOnMePleaseItMakesNoSenseUseTheMenuBarOrKeyboardShortcutToInvokeThisActionIfYouWantToGoMouseFree -(BOOL)canBecomeFocused { return NO; } @end My toolbar is customizable and if I remove this button from the toolbar it seems to fix the problem (though more testing is needed to say for sure).
Topic: UI Frameworks SubTopic: UIKit Tags:
Oct ’23
Reply to Enable WKWebView Web Inspector Under Mac Catalyst?
It's better than nothing but still not as good as being able to open the web inspector from the WKWebView itself because: We have to switch to Safari to get the Web Inspector. and 2) You don't get an "Inspect Element..." menu item when you right click to launch the web inspector in the WKWebView itself.
Topic: Safari & Web SubTopic: General Tags:
Oct ’23