Search results for

column

2,052 results found

Post

Replies

Boosts

Views

Activity

Reply to NavigationSplitView No Toggle Button
Why is there no toggle button above? What do you mean by toggle button? Do you mean the button that hides and shows the sidebar? This is only present when the horizontalSizeClass is .regular. On an iPhone in portrait mode, it won't appear. ‎ And why is the menu always showing? What menu are you talking about? ‎ I cant see the detiail view anymore If you want to see the detail view, you need to select an item from the list. As I said before, the two-column layout with the sidebar toggle button is only present when the horizontalSizeClass is .regular. In your screenshot (an iPhone in portrait mode) the NavigationSplitView collapses down to a single column layout and acts more like a NavigationStack.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’22
Mac Catalyst: UISplitViewControllerColumnSecondary doesn't get key focus when the Tab Key is Pressed in a Triple UISplitViewController.
My UISplitViewController is configured like this: A list (collection view) is used in the primary view controller (sidebar style). When a selection is made in the primary view controller a table view displays data in the supplementary column. When a selection is made in the supplementary view controller, a view controller with scrollable content is shown in the secondary view controller. This is like the Mail app on Mac. So when I run the app I hit the tab key once and the list (collection view) in the primary column gets focus. I can navigate the list with the keyboard. This works as expected. So now with a selection in the list, a table view is showing in the supplementary column. I hit the tab key again and the table view gets focus. This works as expected as I can navigate the table view from the keyboard with the arrow keys. Now with a selection made in the table view, the scrollable view controller is showing in the secondary view controller column. I hit the tab key
3
0
891
Nov ’22
How to fix these errors?
Hello there! I want to create a cards game, and I'm creating it following the Stanford University's tutorial. I followed the video step by step but there is a warning that In the video doesn't appear. Can someone help me to fix it? Here's the link of the video: [https://www.youtube.com/watch?v=oWZOFSYS5GE&t=671s) This is my code: import SwiftUI struct ContentView: View { var emojis =[🚲,🚂,🚁,🚜,🚕,🏎,🚑,🚓,🚒,🚁,🚀,⛵️,🛸,🛶,🚌,🛺,🚇,🚠,🦽,🚗,🚚,🛴,🛵,🚅] @State var emojiCount: Int = 4 var body: some View { ScrollView { LazyVGrid(columns: [GridItem(), GridItem(), GridItem()]) { HStack { ForEach(emojis[0.. 1 { // here's the first error which says Cannot find 'emojiCount' in scope' emojiCount -= 1 // here's the same error which says Cannot find 'emojiCount' in scope' } } label: { Image(systemName: minus.circle) } } var add: some View { Button { if emojiCount < emojis.count { // here's the same error which says Cannot find 'emojiCount' in scope' emojiCount += 1 // here's the same error which says
4
0
600
Oct ’22
Reply to How to fix these errors?
Do you mean those warnings ? if emojiCount > 1 { // here's the first error which says Cannot find 'emojiCount' in scope' emojiCount -= 1 // here's the same error which says Cannot find 'emojiCount' in scope' } You're new to the forum, so welcome. And get a few advices: You'd better expose error messages clearly and not let others search for them in code… when you post code to avoid leaving 20 blank lines… Use Paste and Match Style and then code formatter tool. That will make your code easier to read. I noted several errors: var emojis = [🚲,🚂,🚁,🚜,🚕,🏎,🚑,🚓,🚒,🚁,🚀,⛵️,🛸,🛶,🚌,🛺,🚇,🚠,🦽,🚗,🚚,🛴,🛵,🚅] There need a space after =before [ var remove: some View { is defined out of struct ContentView: View { Hence, @State var emojiCount is not visible out of its scope (the struct). Probably, you have a misplaced closing parenthesis. This should be correct: import SwiftUI struct ContentView: View { var emojis = [🚲,🚂,🚁,🚜,🚕,🏎,🚑,🚓,🚒,🚁,🚀,⛵️,🛸,🛶,🚌,🛺,🚇,🚠,🦽,🚗,🚚,🛴,🛵,🚅] @State var emojiCoun
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’22
Reply to Anchor on Sky? (Yea the clear blue sky)
Yes. You can add your own anchor to the session: https://developer.apple.com/documentation/arkit/arsession/2865612-add To instantiate your own anchor, you can call the anchor initializer with a 4x4 transform: https://developer.apple.com/documentation/arkit/aranchor/2867985-init . Elevation of the space ship in meters above the ground would be the 3rd element in the fourth column of the transform.
Topic: Spatial Computing SubTopic: ARKit Tags:
Oct ’22
Why overlay is not on top
Please see image. I want the text one case per million to extend. but in this scenario, it seems that the image overlay is occupying space inside the the view where the text are located Same as One Death Per People. I think the first line should be One Death Per and maybe because the image is big that it somehow is occupying its area? (But i placed the image in overlay so it should be rendered no top) I think the word Per should still in in the first line. Any idea what could be the problem? This is my code struct Stat: View { var body: some View { VStack { Text(One Case Per People) .frame(maxWidth: .infinity, alignment: .leading) .font(.system(size: 19)) Text(2) .frame(maxWidth: .infinity, alignment: .leading) .font(.system(size: 15)) Spacer() } .padding(8) .frame(minHeight: 100) .cornerRadius(8) .background(Color.gray) .overlay( Image(systemName: person.3.fill) .resizable() .frame(width: 60, height: 60, alignment: .trailing) .padding(8), alignment: .bottomTrailing ) } } I used a grid to display them ScrollV
4
0
1.5k
Oct ’22
Reply to Why overlay is not on top
I think your problem is in the .padding(8) line. When you have that padding it adds 8px to all four external sides of the Text label, making it too small to fit the text on one line. You can achieve your desired look by reducing the font size, too, but that's probably not of much use. I've just put this into a new project, and Xcode is showing the preview in an iPhone 14 Pro (or Max) where the result is perfectly fine, because that device is quite wide. I've added .frame(width 380) to the ScrollView so it can be seen on a smaller screen. I've given the various elements a background colour so you can see where they interact: struct ContentView: View { var body: some View { ScrollView { LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible())]) { Stat() Stat() Stat() Stat() } } .frame(width: 380) // Change this to simulate smaller devices } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } struct Stat: View { var body: some View { VStack { Text(
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’22
UINavigationController inside UISplitViewController's UISplitViewControllerColumnSupplementary Doesn't Appear on Mac Catalyst
Working on a Mac Catalyst app. I have a UInavigationController. On iOS this is full screen but on Mac Catalyst I'm using it inside a UISplitViewController in the supplementary column. This view controller's root view controller has a navigationItem which configures a UISearchController. The search bar is nowhere to be found unless I set it to UINavigationItemSearchBarPlacementStacked. So is UINavigationItemSearchBarPlacementInline not supported for the supplementary column of a UISplitViewController? If that's the case I'm fine with that actually but there's got to be a way to make UINavigationItemSearchBarPlacementStacked look a little better on Mac? The search bar border is barely visible on a white background.
1
0
1.1k
Oct ’22
LazyHGrid Equal Distribution
Wish to ask for suggestions. My goal is to have a view where user inputs an array of strings. Depending on the number of strings, should have equal distribution of spacing between them. E.g. 5 items. 1st item should be top, last item should be bottom while the 2nd-4th should be in between and all of them should have equal spacing. This is what I have import SwiftUI struct MyView: View { @State private var labels: [String]? var labels = [Great, Major, Strong, Moderate, Small] var colors = [.blue, .red] HStack { Spacer() LazyHGrid(rows: [GridItem(.adaptive(minimum: 120))]) { if let labels { Group { ForEach(labels, id:.self) { label in Text(label) } } } } .frame(maxHeight: .infinity) Rectangle() .foregroundColor(.clear) .background(LinearGradient(gradient: Gradient(colors: colors ?? []), startPoint: .top, endPoint: .bottom)) Spacer() } } The result is not what I expected it to be. Notice the orange arrows. If i add more strings, [Great, Major, Strong, Moderate, Small, Great, Major, Strong, Moderate, Small], it b
1
0
459
Oct ’22
Making table header opaque to scrolling rows in SwiftUI
I am working on converting an application I wrote for iOS from using UIKit to using SwiftUI. So far, it looks like I’ve been able to get just about everything working with SwiftUI except for one thing. I have a table view that displays several rows of information in a few columns. The table has a single header at the top containing titles for each column. However, there is an aspect of the table view that introduced an undesirable behavior. When scrolling the content, row scrolling upward would appear underneath the header row. The desire was to have the header row be opaque with regard to the table content yet still allow background content underneath the header to show through. In UIKit I ended up implementing a hack of sorts to prevent content of scrolling rows from appearing directly behind the header. To do this, during scrolling the code was calling the UITableView.rectForHeader method and applying a mask to the layer of any rows that might be intersecting that header rectangle. That m
1
0
672
Oct ’22
Reply to List is Disappearing
`struct ContentView: View { @Environment(.managedObjectContext) var moc @FetchRequest(sortDescriptors: [ SortDescriptor(.date) ]) var taxes: FetchedResults @State private var showingAddScreen = false // @EnvironmentObject var vm = ViewModel() @State var PDFUrls: URL? @State var showSheet: Bool = false @State private var selectedName: String? @State private var expanded: Bool = false let tax: Tax // @State private var items: [Any] = [] // @State private var sheet: Bool = false // let columns = [GridItem(.fixed(50)), GridItem(.fixed(50)), GridItem(.fixed(50)), GridItem(.fixed(50)), GridItem(.fixed(50))] var body: some View { // NavigationView { // VStack { VStack { HStack { // padding() EditButton() // .background(Color.yellow) .padding(.leading, 20) Spacer() Button { exportPDF { self } completion: { status, url in if let url = url, status { self.PDFUrls = url self.showSheet.toggle() } else { print(Failed to produce PDF) } } } label: { Image(systemName: square.and.arrow.up) //.background(Color.yellow)
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’22
Reply to Bug in StoreKit 2 in iOS 15.5-7
Hi, unfortunately this is an issue in Xcode 14.0. The issue is resolved in Xcode 14.1 RC, so if you build your app with that version it will be able to use these properties on iOS versions earlier than iOS 16.0. There is a workaround you can use to use these APIs in apps built with Xcode 14.0 and 14.0.1 listed in the Xcode 14.0 release notes, I'll quote it here: Using the following StoreKit properties and methods on apps with a minimum deployment target below iOS 16, macOS 13, watchOS 9, and tvOS 16 will cause the app to crash at launch when running on systems earlier than iOS 16, macOS 13, watchOS 9 and tvOS 16: priceFormatStyle and subscriptionPeriodFormatStyle on Product values environmentStringRepresentation and recentSubscriptionStartDate on Product.SubscriptionInfo.RenewalInfo values environmentStringRepresentation on Transaction values dateRange(referenceDate:) and formatted(_:referenceDate:) on Product.SubscriptionPeriod values (99962885) (FB11516463) Workaround: For each target using a StoreKit API l
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’22
Fit SwiftUI grid columns to the contents
My grids expand widthways to take up all the space it can. I can stick it in a frame and limit the size. But is there a way to get the columns to shrink to fit the contents plus padding? That would be neater, and probably more robust if the text changes size. FWIW most of my grids contain only text, and I don't use a lot of columns.
1
0
1.5k
Oct ’22
Reply to Passing an array into struct
Sorry this might be better than the previous post... var gameImport = 24,exam.dwindled.span,Short for examination,Reduced gradually in size,The total length of something from end to end,_ _ _ _ . _ w _ _ d _ _ d . _ _ _ n,16,///cracked.shadowed.private,The Vase was (?) when it toppled over,A part of the house is (?) by a tree every day,We like to talk in (?) when we want to keep it : secret,_ _ _ _ _ _ . _ _ _ _ _ _ . _ _ _ a t e,98,///spilling.dances.backbone,Causing or allowing liquid to flow over the edge : of its container,A series of steps that match the speed and : rhythm of a piece of music,The column of bones in the back which sustains : and gives firmness to the frame,_ p _ l l _ n . a _ c _ s._ a _ _ b _ n ,93,///inwards.habitat.buttered,Toward the centre or interior,Place where anything is commonly found,Covered or spread with butter, _ _ w _ r _ . a b t _ t._ u _ _ e _ e d, a e m x , d i l e n , p a s , d r a c c k e , d s a d o w e h , v r p i , g i s i , n d e , k o b c e , n s i a d ,
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’22