-1
var body: some View {

           ScrollView(.horizontal,showsIndicators: false){
           GeometryReader{
                   ViewGeoIndex in

And I get the Error called "Type '()' cannot conform to 'View'" in the following print statement.

I guess maybe there should not be any statements except for the views and stacks(something to be shown on the view)

If so, then where should I put my debug statements like print.

                    print("The centerX of the screen is \(ViewGeoIndex.frame(in:.global).midX)")
                    HStack(alignment:.center,spacing:0){
                    ForEach(CardName.allCases,id:\.self){
                    option in
                          //  Circle().frame(width:10,height: 30)
                        GeometryReader{
                            BarGeoIndex in
                        Button {
                            activeCard=option.title
                            print("Success")
                        } label:{
                                ZStack{
                                Circle().frame(width: 60, height:60, alignment: .center)
                                .foregroundColor(.white)
                                .shadow(color: .gray, radius: 0.5, x: 0.5, y: 0.5)
                                Text(option.image)
                            }//content of the button
                            .frame(width:100)
                        }
                            var BarMidX = BarGeoIndex.frame(in: .global).midX
                           

Here occurs the same problem like the last one.

                            if (BarMidX == ViewGeoIndex.frame(in: .global).midX)
                            {
                                print("Success")
                            }
                            ```
                        }.frame(width:100)
                        
                       
                    }
                    }//HStack
                   .padding([.horizontal],0)
            }
                   // Text("\(index.frame(in: CoordinateSpace.global).midX)")
    
          
        }//ScrollView
            .padding([.horizontal],0)
        }

I have been stuck here for 1 hour. Realllly appreciate if you help me out.

burnsi
  • 6,194
  • 13
  • 17
  • 27

1 Answers1

1

The closure you are in expects to return only Views. But print does not.

You can use the print this way:

let _ = print(...
burnsi
  • 6,194
  • 13
  • 17
  • 27