Discuss the different user interface frameworks available for your app.

All subtopics
Posts under UI Frameworks topic

Post

Replies

Boosts

Views

Activity

Displaying a subtitle for nested UIMenus
The sessions talks about a new subtitle ability for UIMenus (“These buttons also benefit from improvements in menus like the ability for menu items to have subtitles for greater clarity.”) but I cannot find documentation on how to enable said subtitle. Even using the example code with the new .singleSelection option does not display any subtitle.. Anyone did succeed in doing so?
2
0
2.3k
May ’22
Table view with dynamic content - is it possible?
Hi, How can I use a Table view to build a data grid for a dynamic set of data? Say, I have a 2D collection of data elements (a matrix, basically) with variable number of columns, and a 1D collection of column labels (a vector). For the sake of simplicity, let's assume that all data elements are Strings. let data: [[String]]; let columnLabels: [String] How can I build TableColumn definitions without key paths? Thanks!
6
0
3.0k
May ’22
iPhone13 CollectionView issue
When I use UICollectionView on iPhone13 and the latest devices, [collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:section] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES] will cause caton. animated:YES has no animation effect, but this method works well on other devices, They are IOS 15.0.2 systems - (void)topClick:(UIButton *)sender{         if (sender.selected) {         return;     }          NSArray *array = [NSArray array];     if (sender == self.topLuck) {         array = self.luckList;     } else if (sender == self.topLuxurious){         array = self.luxuriousList;     } else if (sender == self.topVip){         array = self.vipList;     } else if (sender == self.topPk){         array = self.pkList;     } else if (sender == self.packetBtn){         array = self.packetList;     }     NSInteger section = [self.datas indexOfObject:array]; //    [self didScrollToSection:section];          if (section < self.datas.count) {         [self.giftCollectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:section] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES];     } } - (UICollectionView *)giftCollectionView{     if (!_giftCollectionView) {         LiveGiftPickerLayout *layout = [LiveGiftPickerLayout new];         layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;         layout.sectionInset = UIEdgeInsetsMake(0, 10, 0, 10);         CGFloat width = floor((kScreen_Width - 20)/4);         layout.itemSize = CGSizeMake(width, width);         layout.minimumLineSpacing = 0;         layout.minimumInteritemSpacing = 0;         _giftCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];         _giftCollectionView.dataSource = self;         _giftCollectionView.delegate = self;         _giftCollectionView.backgroundColor = [UIColor clearColor];         _giftCollectionView.showsHorizontalScrollIndicator = NO;         _giftCollectionView.pagingEnabled = YES;         [_giftCollectionView registerClass:[GiftPickerCollectionViewCell class] forCellWithReuseIdentifier:[GiftPickerCollectionViewCell currentIdentifier]];     }     return _giftCollectionView; }
3
0
1.3k
Apr ’22
Help!!! How to eliminate the ">" nav link symbol from list items?
Have spent 2 hours on this without success, and have not found any info on-line. I've put together a list of items (regular swiftui list) and when I add a Navigation Link, it modifies the list item view to add a ">" symbol to the right of the list item. This is the current code from the list view (calls a sub-view - that works perfect, but I don't want the ">" symbol appearing on each item. List ($viewModel.teams) { Team in NavigationLink(destination: GroupMembersView(user: user, team: Team)) { GroupsCellView(team: Team) }.buttonStyle(PlainButtonStyle()) }.listStyle(.plain) Here is a picture of the nav view & undesired symbol (symbol appears on the right hand side of every item in list): How can I remove this symbol? -thanks!
4
0
7k
Apr ’22
NSPersistentCloudKitContainer Bug
I have been excited to add NSPersistentCloudKitContainer's share functionality to my app but I've noted a few thing I suspect are bugs: -When using share() on a NSManagedObject the share record is set up in a new zone. However, the root NSManagedObject's record is not being updated with the relationship linkage to the shared record. -Secondly, when you revoke a share, the cloudkit.share record is removed from iCloud, but not in the local data stores. This makes the fetchShares() method ineffective for detecting a missing cloudkit.share record. In order to re-share the root object the developer must call out to iCloud directly using the old methods to be sure if the share exists or not. I am using the code from Apple's 'Synchronizing a Local Store to the Cloud' sample. It would be nice if they added support for revoking shares into this sample and addressed these issues.
8
0
6.5k
Apr ’22
How Text Layout Manager generates Layout Fragment from Text Elements?
During the presentation (19:43) it says the NSTextLayoutFragment 'Layout information for one or more elements'. But from the documentation it seems that you can only generate a layout fragment from one NSTextElement. Besides there is only one property that associates a text element. What does it mean by 'parent element' anyway?
0
0
987
Apr ’22
Deleting a Share without deleting Objects
Hi, I wanted to offer the UI for editing and deleting a share. So for using UICloudSharingController(share: , container: ) I implemented the delegate to call "persistUpdatedShare" in "cloudSharingControllerDidSaveShare" func cloudSharingControllerDidSaveShare(_ csc: UICloudSharingController) { if let share = csc.share,   let privatePersistentStore = PersistenceController.shared.privatePersistentStore { PersistenceController.shared.container.persistUpdatedShare(share, in: privatePersistentStore) { (share, error) in Thread.performOnMain { if let error = error { PersistenceController.shared.storeWarning = error } } } } } and to call "purgeObjectsAndRecordsInZone" in "cloudSharingControllerDidStopSharing" func cloudSharingControllerDidStopSharing(_ csc: UICloudSharingController) { let puzzleToShare = puzzleToShare if let share = csc.share,   let privatePersistentStore = PersistenceController.shared.privatePersistentStore { PersistenceController.shared.container.purgeObjectsAndRecordsInZone(with: share.recordID.zoneID, in: privatePersistentStore) { (zoneID, error) in Thread.performOnMain { if let error = error { PersistenceController.shared.storeWarning = error } else { puzzleToShare.makePrivateDuplicate() try? puzzleToShare.puzzle.managedObjectContext?.save() } } } } } I got this implementation from a TSI, but it makes no sense to me to delete and duplicate my objects rather than just keeping them and only deleting the share. Question: How can I cleanly discontinue a share, but keep my data. Duplicating my objects seems such a weird approach. But without this implementation it does not really work. (I get strange behaviors and crashes) All the best Christoph
1
0
1.6k
Mar ’22
Is it possible to set Focus on .searchable in SwiftUI
I am trying to set the focus on the .searchable text entry field using @FocuseState and .focused($focusedField, equals: .search) technique demonstrated by Tanu in her WWDC21-10023 talk, but I'm not sure if it is a focusable element or how to programmatically set it. My attempt: //based on a technique presented in https://developer.apple.com/videos/play/wwdc2021/1002 and Paul Hudson's article https://www.hackingwithswift.com/quick-start/swiftui/how-to-add-a-search-bar-to-filter-your-data import SwiftUI enum Field: Hashable {   case search } struct ContentView: View {   let itemsToSearch = ["John", "Mark", "Adam", "Carol", "Ismael", "Vanessa", "Aniq"]   @FocusState private var focusedField: Field?   @State private var searchText = ""   var body: some View {     NavigationView {       List {         ForEach(searchResults, id: \.self) { itemsToSearch in           NavigationLink(destination: Text(itemsToSearch)) {             Text(itemsToSearch)           }         }       }       .searchable(text: $searchText, placement: .navigationBarDrawer(displayMode: .always)) {         ForEach(searchResults, id: \.self) { result in           Text("\(result)").searchCompletion(result)         }      .focused($focusedField, equals: .search)         .onAppear {           focusedField = .search         }       }     }   }   var searchResults: [String] {     if searchText.isEmpty {       return itemsToSearch     } else {       return itemsToSearch.filter { $0.contains(searchText) }     }   } } struct ContentView_Previews: PreviewProvider {   static var previews: some View {     ContentView()   } } Can someone clarify if this is possible, and if so, where I am going wrong? Thanks in advance. Laith
0
0
2.4k
Mar ’22
Where is the demo project?
I would like to compare what I'm doing (wrongly, it seems) to the video. Where's the demo project? In short, I'm seeing that the runtime is complaining with [SwiftUI] Publishing changes from background threads is not allowed; make sure to publish values from the main thread (via operators like receive(on:)) on model updates. despite using @MainActor. And, it isn't clear where to instantiate the model object. I get a warning Expression requiring global actor 'MainActor' cannot appear in default-value expression of property '_manager'; this is an error in Swift 6 So while this is very promising, it is hard to discover the correct and modern way to implement asynchronous behavior in SwiftUI.
0
0
811
Mar ’22
Impossible to set up layout with view hierarchy unprepared for constraint.
After upgrading to ios15, there are many crashes. What is the reason?? -[UIView _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 468 -[UIView _tryToAddConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 212 -[UIView(UIConstraintBasedLayout) nsli_addConstraint:]  -[UIView(UIConstraintBasedLayout) addConstraints:]_block_invoke + 176 0x000000019b069000 + 34296 -[UIView(UIConstraintBasedLayout) addConstraints:] + 196 -[UIInputWindowControllerHostingItem updateVisibilityConstraintsForPlacement:] + 440 -[UIInputWindowControllerHostingItem updateViewConstraints] + 6888 -[UIInputWindowControllerHosting updateViewConstraints] + -[UIInputWindowController updateViewConstraints] + 92 -[UIInputWindowController changeToInputViewSet:] + 2252 ___43-[UIInputWindowController setInputViewSet:]_block_invoke.1285 + 40 ___77-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]_block_invoke.1042 + 1600 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 724 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 248 -[UIViewAnimationState animationDidStop:finished:] + 244 0x00000001861eb000 + 821768 libdispatch.dylib __dispatch_client_callout + 20
2
0
1.2k
Mar ’22
Will the AppIcon automatically rounded in macOS 11?
Some context from the Human Interface Guidelines. It says that the AppIcon should be square in shape with no rounded edges. But when I build my app with the same image specs using Image Asset Catalog, it does not seems to be rounding the corners automagically. I know it does in iOS and iPadOS, but does it work macOS 11. And what about Icon shapes in older macOS Catalina? Will this change affect them. Square without rounded corners looks kinda ugly.
3
0
5.6k
Feb ’22
Displaying a subtitle for nested UIMenus
The sessions talks about a new subtitle ability for UIMenus (“These buttons also benefit from improvements in menus like the ability for menu items to have subtitles for greater clarity.”) but I cannot find documentation on how to enable said subtitle. Even using the example code with the new .singleSelection option does not display any subtitle.. Anyone did succeed in doing so?
Replies
2
Boosts
0
Views
2.3k
Activity
May ’22
Table view with dynamic content - is it possible?
Hi, How can I use a Table view to build a data grid for a dynamic set of data? Say, I have a 2D collection of data elements (a matrix, basically) with variable number of columns, and a 1D collection of column labels (a vector). For the sake of simplicity, let's assume that all data elements are Strings. let data: [[String]]; let columnLabels: [String] How can I build TableColumn definitions without key paths? Thanks!
Replies
6
Boosts
0
Views
3.0k
Activity
May ’22
iPhone13 CollectionView issue
When I use UICollectionView on iPhone13 and the latest devices, [collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:section] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES] will cause caton. animated:YES has no animation effect, but this method works well on other devices, They are IOS 15.0.2 systems - (void)topClick:(UIButton *)sender{         if (sender.selected) {         return;     }          NSArray *array = [NSArray array];     if (sender == self.topLuck) {         array = self.luckList;     } else if (sender == self.topLuxurious){         array = self.luxuriousList;     } else if (sender == self.topVip){         array = self.vipList;     } else if (sender == self.topPk){         array = self.pkList;     } else if (sender == self.packetBtn){         array = self.packetList;     }     NSInteger section = [self.datas indexOfObject:array]; //    [self didScrollToSection:section];          if (section < self.datas.count) {         [self.giftCollectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:section] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES];     } } - (UICollectionView *)giftCollectionView{     if (!_giftCollectionView) {         LiveGiftPickerLayout *layout = [LiveGiftPickerLayout new];         layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;         layout.sectionInset = UIEdgeInsetsMake(0, 10, 0, 10);         CGFloat width = floor((kScreen_Width - 20)/4);         layout.itemSize = CGSizeMake(width, width);         layout.minimumLineSpacing = 0;         layout.minimumInteritemSpacing = 0;         _giftCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];         _giftCollectionView.dataSource = self;         _giftCollectionView.delegate = self;         _giftCollectionView.backgroundColor = [UIColor clearColor];         _giftCollectionView.showsHorizontalScrollIndicator = NO;         _giftCollectionView.pagingEnabled = YES;         [_giftCollectionView registerClass:[GiftPickerCollectionViewCell class] forCellWithReuseIdentifier:[GiftPickerCollectionViewCell currentIdentifier]];     }     return _giftCollectionView; }
Replies
3
Boosts
0
Views
1.3k
Activity
Apr ’22
Help!!! How to eliminate the ">" nav link symbol from list items?
Have spent 2 hours on this without success, and have not found any info on-line. I've put together a list of items (regular swiftui list) and when I add a Navigation Link, it modifies the list item view to add a ">" symbol to the right of the list item. This is the current code from the list view (calls a sub-view - that works perfect, but I don't want the ">" symbol appearing on each item. List ($viewModel.teams) { Team in NavigationLink(destination: GroupMembersView(user: user, team: Team)) { GroupsCellView(team: Team) }.buttonStyle(PlainButtonStyle()) }.listStyle(.plain) Here is a picture of the nav view & undesired symbol (symbol appears on the right hand side of every item in list): How can I remove this symbol? -thanks!
Replies
4
Boosts
0
Views
7k
Activity
Apr ’22
NSPersistentCloudKitContainer Bug
I have been excited to add NSPersistentCloudKitContainer's share functionality to my app but I've noted a few thing I suspect are bugs: -When using share() on a NSManagedObject the share record is set up in a new zone. However, the root NSManagedObject's record is not being updated with the relationship linkage to the shared record. -Secondly, when you revoke a share, the cloudkit.share record is removed from iCloud, but not in the local data stores. This makes the fetchShares() method ineffective for detecting a missing cloudkit.share record. In order to re-share the root object the developer must call out to iCloud directly using the old methods to be sure if the share exists or not. I am using the code from Apple's 'Synchronizing a Local Store to the Cloud' sample. It would be nice if they added support for revoking shares into this sample and addressed these issues.
Replies
8
Boosts
0
Views
6.5k
Activity
Apr ’22
How Text Layout Manager generates Layout Fragment from Text Elements?
During the presentation (19:43) it says the NSTextLayoutFragment 'Layout information for one or more elements'. But from the documentation it seems that you can only generate a layout fragment from one NSTextElement. Besides there is only one property that associates a text element. What does it mean by 'parent element' anyway?
Replies
0
Boosts
0
Views
987
Activity
Apr ’22
Deleting a Share without deleting Objects
Hi, I wanted to offer the UI for editing and deleting a share. So for using UICloudSharingController(share: , container: ) I implemented the delegate to call "persistUpdatedShare" in "cloudSharingControllerDidSaveShare" func cloudSharingControllerDidSaveShare(_ csc: UICloudSharingController) { if let share = csc.share,   let privatePersistentStore = PersistenceController.shared.privatePersistentStore { PersistenceController.shared.container.persistUpdatedShare(share, in: privatePersistentStore) { (share, error) in Thread.performOnMain { if let error = error { PersistenceController.shared.storeWarning = error } } } } } and to call "purgeObjectsAndRecordsInZone" in "cloudSharingControllerDidStopSharing" func cloudSharingControllerDidStopSharing(_ csc: UICloudSharingController) { let puzzleToShare = puzzleToShare if let share = csc.share,   let privatePersistentStore = PersistenceController.shared.privatePersistentStore { PersistenceController.shared.container.purgeObjectsAndRecordsInZone(with: share.recordID.zoneID, in: privatePersistentStore) { (zoneID, error) in Thread.performOnMain { if let error = error { PersistenceController.shared.storeWarning = error } else { puzzleToShare.makePrivateDuplicate() try? puzzleToShare.puzzle.managedObjectContext?.save() } } } } } I got this implementation from a TSI, but it makes no sense to me to delete and duplicate my objects rather than just keeping them and only deleting the share. Question: How can I cleanly discontinue a share, but keep my data. Duplicating my objects seems such a weird approach. But without this implementation it does not really work. (I get strange behaviors and crashes) All the best Christoph
Replies
1
Boosts
0
Views
1.6k
Activity
Mar ’22
Is it possible to set Focus on .searchable in SwiftUI
I am trying to set the focus on the .searchable text entry field using @FocuseState and .focused($focusedField, equals: .search) technique demonstrated by Tanu in her WWDC21-10023 talk, but I'm not sure if it is a focusable element or how to programmatically set it. My attempt: //based on a technique presented in https://developer.apple.com/videos/play/wwdc2021/1002 and Paul Hudson's article https://www.hackingwithswift.com/quick-start/swiftui/how-to-add-a-search-bar-to-filter-your-data import SwiftUI enum Field: Hashable {   case search } struct ContentView: View {   let itemsToSearch = ["John", "Mark", "Adam", "Carol", "Ismael", "Vanessa", "Aniq"]   @FocusState private var focusedField: Field?   @State private var searchText = ""   var body: some View {     NavigationView {       List {         ForEach(searchResults, id: \.self) { itemsToSearch in           NavigationLink(destination: Text(itemsToSearch)) {             Text(itemsToSearch)           }         }       }       .searchable(text: $searchText, placement: .navigationBarDrawer(displayMode: .always)) {         ForEach(searchResults, id: \.self) { result in           Text("\(result)").searchCompletion(result)         }      .focused($focusedField, equals: .search)         .onAppear {           focusedField = .search         }       }     }   }   var searchResults: [String] {     if searchText.isEmpty {       return itemsToSearch     } else {       return itemsToSearch.filter { $0.contains(searchText) }     }   } } struct ContentView_Previews: PreviewProvider {   static var previews: some View {     ContentView()   } } Can someone clarify if this is possible, and if so, where I am going wrong? Thanks in advance. Laith
Replies
0
Boosts
0
Views
2.4k
Activity
Mar ’22
Where is the demo project?
I would like to compare what I'm doing (wrongly, it seems) to the video. Where's the demo project? In short, I'm seeing that the runtime is complaining with [SwiftUI] Publishing changes from background threads is not allowed; make sure to publish values from the main thread (via operators like receive(on:)) on model updates. despite using @MainActor. And, it isn't clear where to instantiate the model object. I get a warning Expression requiring global actor 'MainActor' cannot appear in default-value expression of property '_manager'; this is an error in Swift 6 So while this is very promising, it is hard to discover the correct and modern way to implement asynchronous behavior in SwiftUI.
Replies
0
Boosts
0
Views
811
Activity
Mar ’22
Impossible to set up layout with view hierarchy unprepared for constraint.
After upgrading to ios15, there are many crashes. What is the reason?? -[UIView _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 468 -[UIView _tryToAddConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 212 -[UIView(UIConstraintBasedLayout) nsli_addConstraint:]  -[UIView(UIConstraintBasedLayout) addConstraints:]_block_invoke + 176 0x000000019b069000 + 34296 -[UIView(UIConstraintBasedLayout) addConstraints:] + 196 -[UIInputWindowControllerHostingItem updateVisibilityConstraintsForPlacement:] + 440 -[UIInputWindowControllerHostingItem updateViewConstraints] + 6888 -[UIInputWindowControllerHosting updateViewConstraints] + -[UIInputWindowController updateViewConstraints] + 92 -[UIInputWindowController changeToInputViewSet:] + 2252 ___43-[UIInputWindowController setInputViewSet:]_block_invoke.1285 + 40 ___77-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]_block_invoke.1042 + 1600 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 724 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 248 -[UIViewAnimationState animationDidStop:finished:] + 244 0x00000001861eb000 + 821768 libdispatch.dylib __dispatch_client_callout + 20
Replies
2
Boosts
0
Views
1.2k
Activity
Mar ’22
Will the AppIcon automatically rounded in macOS 11?
Some context from the Human Interface Guidelines. It says that the AppIcon should be square in shape with no rounded edges. But when I build my app with the same image specs using Image Asset Catalog, it does not seems to be rounding the corners automagically. I know it does in iOS and iPadOS, but does it work macOS 11. And what about Icon shapes in older macOS Catalina? Will this change affect them. Square without rounded corners looks kinda ugly.
Replies
3
Boosts
0
Views
5.6k
Activity
Feb ’22