I want to use this code for content view but some variable not exisist how can sovle the problem?
error : Cannot find 'UIDevice' in scope
I scrabbed the code frome there for Alignment Guide
I want to use this code for content view but some variable not exisist how can sovle the problem?
error : Cannot find 'UIDevice' in scope
I scrabbed the code frome there for Alignment Guide
Hi @think-j
It's not a missing variable, but a (potentially) missing import. UIDevice is part of UIKit, and as such only available on iOS/iPadOS. The part this code is using: UIDevice.current.userInterfaceIdiom == .pad
is only relevant on those platforms - so if you're not constraining this code to just iOS, that's likely going to be part of the problem.
I suspect if you tack on import UIKit
with the import SwiftUI
, you won't have any trouble for iOS and iPadOS.