Posts

Post not yet marked as solved
2 Replies
1.2k Views
I followed SwiftUI Tutorials:https://developer.apple.com/tutorials/swiftui/building-lists-and-navigationand there s a methodpreviewdeviceto add device name to prview codeshttps://developer.apple.com/documentation/swiftui/view/3278637-previewdevicehere is my code:struct LandmarkList_Previews: PreviewProvider { static var previews: some View { ForEach(["iPhone SE", "iPhone XS Max", "iPad Pro (9.7-inch)", "Apple TV"], id: \.self) { deviceName in LandmarkList() .previewDevice(PreviewDevice(rawValue: deviceName)) .previewDisplayName(deviceName) } } }so when I do the preview, I can see iPhone, but I just see a blank page in iPad
Posted
by FujiApple.
Last updated
.
Post not yet marked as solved
3 Replies
2.1k Views
I am using ForEach() inside a Picker, but the debug gives an error.Xcode Version 11.2 (11B52)Below is my swift codevar radiusRangeKM = Array((stride(from: 50, to: 2010, by: 10))) var body: some View { NavigationView { //TODO: Form Set Up Form { Section() { Picker(selection: $selectedRadius, label: Text("Radius(KM)")) { ForEach(0 ..< radiusRangeKM.count, id: \.self) { Text(String(self.radiusRangeKM[$0])).tag($0) } } } } .navigationBarTitle(Text("Settings")) } }Below is the error from debug window[TableView] Warning once only: UITableView was told to layout its visible cells and other contents without being in the view hierarchy (the table view or one of its superviews has not been added to a window). This may cause bugs by forcing views inside the table view to load and perform layout without accurate information (e.g. table view bounds, trait collection, layout margins, safe area insets, etc), and will also cause unnecessary performance overhead due to extra layout passes. Make a symbolic breakpoint at UITableViewAlertForLayoutOutsideViewHierarchy to catch this in the debugger and see what caused this to occur, so you can avoid this action altogether if possible, or defer it until the table view has been added to a window. Table view: <_TtC7SwiftUIP33_BFB370BA5F1BADDC9D83021565761A4925UpdateCoalescingTableView: 0x7f9d5e98b000; baseClass = UITableView; frame = (0 0; 414 842); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = ; layer = ; contentOffset: {0, -108}; contentSize: {414, 8702.0000000000109}; adjustedContentInset: {108, 0, 34, 0}; dataSource: <_TtGC7SwiftUIP13$7fff2c6b223419ListCoreCoordinatorGVS_20SystemListDataSourceOs5Never_GOS_19SelectionManagerBoxS2___: 0x7f9d5cf80c50>>
Posted
by FujiApple.
Last updated
.