Post

Replies

Boosts

Views

Activity

Get UICollectionLayoutSectionOrthogonalScrollingBehaviorGroupPaging like behavior for NSCollectionLayoutItems in UICollectionViewCompositionalLayout?
I have a horizontal section in my compositional layout with three items. 0 ---- 1 ----2 When scrolling toward the center I want the scrolling to snap the item at index 1 to the center of the screen. However I can't figure out how to precisely control horizontal scrolling with compositional layout (it doesn't seem possible to control the contentOffset of horizontal scrolling). When I enable paging using UICollectionLayoutSectionOrthogonalScrollingBehaviorPaging the page size assumes full device width and paging works for the item at index 0 or 2 but then the item at index 1 can never be displayed fully on screen (only one half of its width can be shown at a given time). I tried adding leading and trailing space to the group but that didn't work. When I try the UICollectionLayoutSectionOrthogonalScrollingBehaviorGroupPaging the section is displayed with the item at index 1 centered but scrolling doesn't work. I think what I'm looking for is UICollectionLayoutSectionOrthogonalScrollingBehaviorGroupPaging but at the item level or to be able to adjust the contentOffset on the scroll view at the end of dragging. Is there any way I can programmatically access the scroll view being using for horizontal scrolling? I see in the visibleItemsInvalidationHandler I'm able to get the content offset but I'm not able to change it to support snapping.
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
720
Aug ’23
Mac Catalyst with Live Previews: Any Way to Change the Size the View Controller Preview is Rendered at?
I have a Mac Catalyst app. When using "Live Previews" in Xcode 15 for a view controller of mine the live preview renders at a gigantic size in the Preview. This view controller is only ever presented as a "sheet" on Mac at a fixed size so ideally I'd like to be able to specify the "window size" for the preview environment. Is there a way to do this? Thanks in advance.
0
0
495
Sep ’23
Collection View Compositional Layout: uniformAcrossSiblingsWithEstimate Not Working
New in iOS 17 is NSCollectionLayoutDimension uniformAcrossSiblingsWithEstimate: method. I have two collection view items positioned side by side in a a grid and would like to use this feature to give them equal heights. I configure the items like so: -Each "box" in grid is made up of two vertical items -Title item configured with a fractional width of 0.5 and a estimated height. -Description item configured with a fractional width of 0.5 and a estimated height. Then the "box" wraps both the "title item" and a description item vertically NSCollectionLayoutSize *boxSize = [NSCollectionLayoutSize sizeWithFractionalWidth:0.5 estHeightUniformAcrossSiblings:estTitleHeight+estDescriptionheight]]; NSCollectionLayoutGroup *boxGroup = [NSCollectionLayoutGroup verticalGroupWithLayoutSize:boxSize subitems:@[titleItem,descriptionItem]]; //Repeat the box twice to make a side by side grid. //entireRowSize is fractional width of 1.0 and estimated height (not uniform across siblings). NSCollectionLayoutGroup *sideBySideGroup = [NSCollectionLayoutGroup horizontalGroupWithLayoutSize:entireRowSize repeatingSubitem:boxGroup count:2]; But at runtime the grids do not have equal heights. It looks exactly the same as it was on iOS 16. Am I doing something wrong? Thanks in advance.
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
635
Oct ’23
NSToolbar Draws On Top of "Full Screen" Video Played in WKWebView in Mac Catalyst app
I have a Mac Catalyst app configured like so: The root view controller on the window is a tripe split UISplitViewController. The secondary view controller in the Split View controller is a view controller that uses WKWebView. Load a website in the WKWebview that has a video. Expand the video to “Full screen” (on Mac Catalyst this is only “Full window” because the window does not enter full screen like AppKit apps do). The NSToolbar overlaps the “Full screen video.” On a triple Split View controller only the portions of the toolbar in the secondary and supplementary columns show through (the video actually covers the toolbar area in the “primary” column). The expected results: -For the video to cover the entire window including the NSToolbar. Actual results: The NSToolbar draw on top of the video. -- Anyone know of a workaround? I filed FB13229032
0
0
634
Oct ’23
AVAudioMixerNode outputVolume range?
According to the header file the outputVolume properties supported range is 0.0-1.0: /*! @property outputVolume @abstract The mixer's output volume. @discussion This accesses the mixer's output volume (0.0-1.0, inclusive). @property (nonatomic) float outputVolume; However when setting the volume to 2.0 the audio does indeed play louder. Is the header file out of date and if so, what is the supported range for outputVolume? Thanks
0
0
79
Apr ’25
Exposing Objective-C API to Swift inside a Framework (Private Framework API)
My framework has private Objective-C API that is only used within the framework. It should not be exposed in the public interface (so it shouldn't be imported in the umbrella header). To expose this API to Swift that's within the framework only the documentation seems to indicate that this needs to be imported in the umbrella header? Import Code Within a Framework Target To use the Objective-C declarations in files in the same framework target as your Swift code, configure an umbrella header as follows: 1.Under Build Settings, in Packaging, make sure the Defines Module setting for the framework target is set to Yes. 2.In the umbrella header, import every Objective-C header you want to expose to Swift. Swift sees every header you expose publicly in your umbrella header. The contents of the Objective-C files in that framework are automatically available from any Swift file within that framework target, with no import statements. Use classes and other declarations from your Objective-C code with the same Swift syntax you use for system classes. I would imagine that there must be a way to do this?
0
0
306
Jul ’25
Inset or disable NSSheetEffectDimmingView when presenting a sheet?
I have an NSWindow that isn't entirely opaque. When presenting a sheet AppKit overlays the window with NSSheetEffectDimmingView. The problem is the entire window frame is used so NSSheetEffectDimmingView overlays the transparent areas of the window and it looks bad. Is there a clean way to inset NSSheetEffectDimmingView or even perhaps disable this behavior completely so I can draw my own? I'm looking for a clean solution (other than modifying the view hierarchy of NSNextStepFrame) or swizzles which I might have to resort to if there is no other way.
Topic: UI Frameworks SubTopic: AppKit Tags:
0
0
113
Sep ’25
NSButtons with NSBezelStyleGlass Sometimes Very Long Delay Before Adjusting Appearance After Toggling Dark Mode
I have some buttons. I set the bezelStyle to NSBezelStyleGlass. I'm sometimes experiencing the following issue: Put the system in dark mode. Some glass buttons still draw with the light appearance. One or more of the following actions usually makes the appearance redraw proper: -Clicking the button -Deactivating and then reactivating the window. -Close and then reopen the window. I tried setNeedsDisplay YES etc. but that didn't work The delay is quite noticeable. Everything else is in dark mode except one or two glass buttons. This seems to workaround the issue: BOOL didToggleGlass = NO; if (self.bezelStyle == NSBezelStyleGlass) { // Turn glass off just for a sec. self.bezelStyle = NSBezelStyleToolbar; didToggleGlass = YES; } if (didToggleGlass) { // Put glass back on. self.bezelStyle = NSBezelStyleGlass; } Apparently toggling glass cause the effective appearance to change so you can't use the above workaround in a -viewDidChangeEffectiveAppearance b/c you'll create an infinite loop unless you guard against it.
Topic: UI Frameworks SubTopic: AppKit Tags:
0
0
66
Sep ’25
NSBrowser Column Resizing Causes NSWindowWillStartLiveResizeNotification to be posted even though the window isn't being resized.
I have an NSBrowser inside a window. When I start resizing a column I noticed a peculiar behavior: it causes NSWindowWillStartLiveResizeNotification to get posted for the NSWindow the browser is inside (and did end gets posted when column resizing finishes). The browser is not the NSWindow contentView but a descendant of the contentView. I have my reasons for caring (I'm currently listening for these window resize notifications) but my code naively assumes that NSWindowWillStartLiveResizeNotification - NSWindowDidEndLiveResizeNotification indicates a window resizing session, not a column resizing session for the NSBrowser. This is in contrast to NSOutlineView. When resizing columns in NSOutlineView the window resize notifications do not get posted. NSBrowser deliberately kicks it off: -[NSWindow _startLiveResize]; -[NSBrowser _resizeColumn:withEvent:] () So this seems quite intentional but is it necessary in modern macOS? Should I file a bug? I already did FB20298148
Topic: UI Frameworks SubTopic: AppKit Tags:
0
0
111
Sep ’25