Interface Builder

RSS for tag

Build interfaces for applications without writing code using Interface Builder, an editor within Xcode.

Posts under Interface Builder tag

200 Posts

Post

Replies

Boosts

Views

Activity

Duplicate a ViewController on Canvas
I was able to duplicate (option + Drag) a ViewController on my canvas the first time, although wasn't easy. The second time, I had so much trouble to get it to work, then finally (option + drag) worked again. I am trying to duplicate the 3rd time and it still is not working. I am able to copy paste the ViewController, the only issue is that I have no visual representation on the canvas, while I do have the duplicate in the document outline and I can do what ever I want to it there, however I prefer seeing a visual rep. on the canvas as well. Is this a bug in Xcode 15 that I am not able to easily (option + drag) a ViewController to duplicate it, like it is done for the UI Objects. On that note it (option + dark) is also a hassle to get it to work the first time even up to the 4 time around on the ViewController itself. Any ideas or info is appreciated.
0
0
677
Jun ’23
Accessing Interface Builder GUI Controls Anywhere in the App
I used the Interface Builder to place a Switch object in a view. I ctrl dragged it into the Assistant to make its handler a method of the class the view's is in, which is itself a subclass of "UITableViewController". A dialog box appear into which I entered the function name, and select the the option to have the sender as an argument. The result is function of the form: @IBAction func switchStateChange(_ sender: UISwitch) { } Now I need to query this Switch's On/Off state from elsewhere in the program, and if necessary change its state. It is not a good solution to save the sender parameter to a global variable because then it would require the user to change this switch's state before that global variable is set. What is needed is to identify, and lookup, this switch object to access it from anywhere in the application. How is this done?
1
0
779
Jun ’23
Storyboard Boolean Switch Object
The Storyboard Interface Builder has a Switch object that toggles between On, and Off, states. While in the On state it looks normal. While in the Off state it is grayed out. I have a use for this object for the user to toggle between two options which are other than On, and Off. For my intended use its Off state gray out is undesirable. Is there way to prevent this switch graying out in its Off state?
0
0
426
Jun ’23
Xcode 14.3 - Failed to render and update auto layout status
Since updating to Xcode 14.3 every view controller in every storyboard is not updating its IBDesignable's with an error saying it can't find the right .app with the right architecture. This all worked fine in Xcode 14.2 I'm running on an M1 mac mini Error below: /Users/****/Documents/Projects/****/****/Modules/Onboarding/Base.lproj/Onboarding.storyboard Failed to render and update auto layout status for ****ViewController (3EC-3V-hGn): dlopen(****.app, 0x0001): tried: '/****' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot****.app' (no such file), '****.app' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')) I've tried following a stackoverflow post that suggested changing "Build Active Architecture Only" to "No" for debug builds. When I rebuilt I got a prompt from Xcode saying the build failed, and it asked me to turn on Rosetta to try again. I didn't try this as it seemed like this is broken, given it works fine on 14.2
7
3
4.2k
Jun ’23
XCode 14.0 - Safe Area badly sized for landscape
Hello, I have been working with storyboards for my projects without any problems. However, since the XCode Version 14.0 (14A309), the "safe area" on the storyboard preview is wrong for landscape orientation, as you can see in the image below: The "safe area" acts as in portrait (with margins on top and bottom) instead of margins on the left and right side as in the previous version. Also changing the device for preview does not help. It seems to affect only the preview, as the safe area is well in place after building it on both iPhone 13 and iPhone 12 mini. Do you have any idea how to fix this? Or is it a bug that should be fixed by the Apple developer team? Thanks
14
5
4.7k
Jun ’23
Progress Indicator not working as expected
I have a test project with a bar progress indicator create on Ventura with Xcode 14.3.1., It does not show the any animation until the @IBAction function completes. I want to show progress as it progresses not a just the end? Any ideas how to fix this? Below is my test project code.. // // ViewController.swift // ProgressTest // // Created by Bob on 6/5/23. // import Cocoa class ViewController: NSViewController { @IBOutlet weak var progressIndicator: NSProgressIndicator! // var progress: Double = 0.0 override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } override var representedObject: Any? { didSet { // Update the view, if already loaded. } } @IBAction func progressStart(_ sender: Any) { // Start the progress animation progressIndicator.startAnimation(self) // Do some work here... // Do some work here... var progress: Double = 0.0 for _ in 0..<100 { // Update the progress value in a loop progress += 1.0 progressIndicator.doubleValue = progress // progress = Double(i) // progressIndicator.increment(by: 10) // progressIndicator.doubleValue = progress // Do some work here... } // Stop the progress animation progressIndicator.stopAnimation(self) } } thanks Bob
3
0
1.4k
Jun ’23
Image asset not recognized in interface builder
I added an asset catalog to an old iOS project that I'm in the process of updating. The app was originally created before asset catalogs existed. I added an image and an icon set to my catalog. The icon works, and the image shows up when I run the app, but Interface Builder doesn't recognize the image by name when I type it into the Image field on an imageview. I'm guessing that there is something somewhere which causes interface builder to read an asset catalog, which is probably not set on my old project, but I can't figure out what it is. Thanks, Frank
0
0
749
Jun ’23
Safe Area unaware of hidden tab bar
Any hints or experience with the safe area and a hidden tab bar on iPhone X would be appreciated!We've been making updates to our app for iPhone X and we've run into one issue we haven't been able to resolve.Our app uses a UITabBarController. On some screens that are hierarchically below the UITabBarController, we hide the tab bar. On these screens, we normally have a bottom action bar of our own making that has a couple of action buttons in it. We hide the tab bar because it's odd to have this action bar above a tab bar both visually and when touching buttons (because it can be easy to mistap and activate a tab when an action button was the target or vice-versa).The problem occurs when we create one of these views. The view is defined via a UIViewController in an xib. If we create constraints from a subview (say, the bottom of a top level table view or the action bar itself) in the xib to the bottom of the safe area of the view controller's main view, the layout at runtime acts as though the tab bar is still visible even though it is hidden. So we have a space at the bottom of the screen that is the height of the bottom home button plus the tab bar height.After looking for solutions that didn't require specific checks for an iPhone X and iOS 11 (because iOS 10 doesn't have the issue), I relented and started trying anything that could work. If I create two constraints, one with a zero constant to the bottom safe area and one that forces the main view downward by the height of the tab bar, and then only make one of them active depending on what device and OS version is being run, it appears to work. Until it doesn't.The first layout of the screen on iPhone X will work, but if we then (for example) show a modal screen and then return to the first screen, the layout will be incorrect again. The bottom of the main view will go off the bottom of the screen.Uhg.
3
0
7.6k
May ’23
Xcode 13/14 -- Interface Builder Forgets State
Whenever I switch away from a Nib file and then come back to it, Interface Builder "resets" its state. That is, the left-hand outlineView that shows the structure of an IB document collapses to a stupid "minimized" width and the canvas has scrolled away from the view/window I had selected before switching away from IB. This has been a constant issue in Xcode 13 and persists in Xcode 14 Beta 2. Is anyone else seeing this behavior? I have filed multiple Radars about it over the last year and not one has gotten a response (shocking, I know).
2
0
1.4k
May ’23
How Can I Disable Auto Layout?
I have some NSPanels that are not resizable, the App is not localized and and don't need Layout Constraints. Any time I edit an NSText field in the .xib, XCode 14.2 starts to report many errors: "Views without any layout constraints may clip their content or overlap other views." I spent a lot of time trying to make XCode stop reporting these warnings, but I can't. Sometimes quiting XCode or restarting my Mac will make these go away. According to XCode Help: "Auto Layout is enabled by default. To disable Auto Layout, choose View > Inspectors > Show File Inspector and deselect the checkbox for Use Auto Layout." Too bad there isn't any checkbox for Use Auto Layout in the file inspector for the .xib, the .panel's view or the NSText Field so I can't actually do this. The editor>Layout>Automatic menu item is disabled. Is there really any way to disable Auto Layout or has Apple decided to require it?
4
0
3.1k
May ’23
NSUnknownKeyException when connecting property IB
I am trying to integrate a UIKit view into my SwiftUI project using UIViewRepresentable as an intermediate. A TestViewVC.swift file was created containing just a simple IBOutlet: import Foundation import UIKit class TestViewVC: UIViewController { @IBOutlet weak var testLabel: UILabel! } A corresponding TestViewVC.xib file was creating containing just a single label centred on screen. The TestViewVC was then assigned as the File Owner's class. These are then displayed within the SwiftUI context through the use of a TestRepresentableView.swift and TestViewVC.swift class (shown below). //TestRepresentableView.swift import SwiftUI struct TestRepresentableView: UIViewRepresentable { func makeUIView(context: Context) -> UIView { // Load the XIB file and return its view let nib = UINib(nibName: "TestViewVC", bundle: nil) return nib.instantiate(withOwner: nil, options: nil)[0] as! UIView } func updateUIView(_ uiView: UIView, context: Context) { // Update the view here if needed } } //TestViewVC.swift import SwiftUI @main struct TestApp: App { var body: some Scene { WindowGroup { TestRepresentableView() } } } The app runs fine on debug however an NSUnknownKeyException is raised whenever label is connected to the IBOutlet. (Or any other outlet for that matter, even simply connecting the view results in the same error). Any idea of which this is happening?
1
0
649
May ’23
Xcode 11 Unknown class in Interface Builder file.
HiI recently updated to Xcode 11 GM seed. However I've noticed that the dreaded "Unknown class in Interface Builder file" is crashing my app. I haven't changed any class names or storyboards. Interestingly the app runs perfectly in teh simulator, but crashed on my phone.Here is what is being printed in the output window:MyAppName[9513:4230222] Unknown class _TtC10MyApp24SlideTableViewController in Interface Builder file.Could not cast value of type 'UIViewController' (0x1ebe282b0) to 'MyApp.SlideTableViewController' (0x104d05e08).MyAppName[9513:4230222] Could not cast value of type 'UIViewController' (0x1ebe282b0) to 'MyApp.SlideTableViewController' (0x104d05e08).I've deleted the class and recreated, removed the View Controller from the story board, made sure the view controller is references correctly as is the target, but the problem persists and I'm out of ideas.Is there a "reset" of the storyboard to reference the elements? Or some other way to resolve this?Many thanksCraig
7
0
26k
May ’23
Problem with NSTableView constraints
Hi, the problem is not dangerous to life, I don't want see the yellow button on top of the editor. 'Autoresizing Mask' is set to about 50 items, that works, except tableView, 10 warnings. The tableView has 10 columns of 20 pixels width, min 10 and max 100000. The ' Add new constraints' options are all grayed, so what ? In an other project a warning was set for arrayController, I don't like Auto Layout, the blue help lines are enough. My question is : How do i can suppress this warnings ? Kindly, Uwe
0
0
1.2k
May ’23
Duplicate a ViewController on Canvas
I was able to duplicate (option + Drag) a ViewController on my canvas the first time, although wasn't easy. The second time, I had so much trouble to get it to work, then finally (option + drag) worked again. I am trying to duplicate the 3rd time and it still is not working. I am able to copy paste the ViewController, the only issue is that I have no visual representation on the canvas, while I do have the duplicate in the document outline and I can do what ever I want to it there, however I prefer seeing a visual rep. on the canvas as well. Is this a bug in Xcode 15 that I am not able to easily (option + drag) a ViewController to duplicate it, like it is done for the UI Objects. On that note it (option + dark) is also a hassle to get it to work the first time even up to the 4 time around on the ViewController itself. Any ideas or info is appreciated.
Replies
0
Boosts
0
Views
677
Activity
Jun ’23
Accessing Interface Builder GUI Controls Anywhere in the App
I used the Interface Builder to place a Switch object in a view. I ctrl dragged it into the Assistant to make its handler a method of the class the view's is in, which is itself a subclass of "UITableViewController". A dialog box appear into which I entered the function name, and select the the option to have the sender as an argument. The result is function of the form: @IBAction func switchStateChange(_ sender: UISwitch) { } Now I need to query this Switch's On/Off state from elsewhere in the program, and if necessary change its state. It is not a good solution to save the sender parameter to a global variable because then it would require the user to change this switch's state before that global variable is set. What is needed is to identify, and lookup, this switch object to access it from anywhere in the application. How is this done?
Replies
1
Boosts
0
Views
779
Activity
Jun ’23
Storyboard Boolean Switch Object
The Storyboard Interface Builder has a Switch object that toggles between On, and Off, states. While in the On state it looks normal. While in the Off state it is grayed out. I have a use for this object for the user to toggle between two options which are other than On, and Off. For my intended use its Off state gray out is undesirable. Is there way to prevent this switch graying out in its Off state?
Replies
0
Boosts
0
Views
426
Activity
Jun ’23
Looking up code connected to a storyboard's button
I have seen how to connect a button in a storyboard view to code that does its action by dragging that button into the assistant editor. Now I need to do the opposite. There is a button in the storyboard view that is already connected to code. How can that existing already connected code be quickly looked up for a button?
Replies
0
Boosts
0
Views
515
Activity
Jun ’23
Xcode 14.3 - Failed to render and update auto layout status
Since updating to Xcode 14.3 every view controller in every storyboard is not updating its IBDesignable's with an error saying it can't find the right .app with the right architecture. This all worked fine in Xcode 14.2 I'm running on an M1 mac mini Error below: /Users/****/Documents/Projects/****/****/Modules/Onboarding/Base.lproj/Onboarding.storyboard Failed to render and update auto layout status for ****ViewController (3EC-3V-hGn): dlopen(****.app, 0x0001): tried: '/****' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot****.app' (no such file), '****.app' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')) I've tried following a stackoverflow post that suggested changing "Build Active Architecture Only" to "No" for debug builds. When I rebuilt I got a prompt from Xcode saying the build failed, and it asked me to turn on Rosetta to try again. I didn't try this as it seemed like this is broken, given it works fine on 14.2
Replies
7
Boosts
3
Views
4.2k
Activity
Jun ’23
XCode 14.0 - Safe Area badly sized for landscape
Hello, I have been working with storyboards for my projects without any problems. However, since the XCode Version 14.0 (14A309), the "safe area" on the storyboard preview is wrong for landscape orientation, as you can see in the image below: The "safe area" acts as in portrait (with margins on top and bottom) instead of margins on the left and right side as in the previous version. Also changing the device for preview does not help. It seems to affect only the preview, as the safe area is well in place after building it on both iPhone 13 and iPhone 12 mini. Do you have any idea how to fix this? Or is it a bug that should be fixed by the Apple developer team? Thanks
Replies
14
Boosts
5
Views
4.7k
Activity
Jun ’23
Progress Indicator not working as expected
I have a test project with a bar progress indicator create on Ventura with Xcode 14.3.1., It does not show the any animation until the @IBAction function completes. I want to show progress as it progresses not a just the end? Any ideas how to fix this? Below is my test project code.. // // ViewController.swift // ProgressTest // // Created by Bob on 6/5/23. // import Cocoa class ViewController: NSViewController { @IBOutlet weak var progressIndicator: NSProgressIndicator! // var progress: Double = 0.0 override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } override var representedObject: Any? { didSet { // Update the view, if already loaded. } } @IBAction func progressStart(_ sender: Any) { // Start the progress animation progressIndicator.startAnimation(self) // Do some work here... // Do some work here... var progress: Double = 0.0 for _ in 0..<100 { // Update the progress value in a loop progress += 1.0 progressIndicator.doubleValue = progress // progress = Double(i) // progressIndicator.increment(by: 10) // progressIndicator.doubleValue = progress // Do some work here... } // Stop the progress animation progressIndicator.stopAnimation(self) } } thanks Bob
Replies
3
Boosts
0
Views
1.4k
Activity
Jun ’23
Image asset not recognized in interface builder
I added an asset catalog to an old iOS project that I'm in the process of updating. The app was originally created before asset catalogs existed. I added an image and an icon set to my catalog. The icon works, and the image shows up when I run the app, but Interface Builder doesn't recognize the image by name when I type it into the Image field on an imageview. I'm guessing that there is something somewhere which causes interface builder to read an asset catalog, which is probably not set on my old project, but I can't figure out what it is. Thanks, Frank
Replies
0
Boosts
0
Views
749
Activity
Jun ’23
Safe Area unaware of hidden tab bar
Any hints or experience with the safe area and a hidden tab bar on iPhone X would be appreciated!We've been making updates to our app for iPhone X and we've run into one issue we haven't been able to resolve.Our app uses a UITabBarController. On some screens that are hierarchically below the UITabBarController, we hide the tab bar. On these screens, we normally have a bottom action bar of our own making that has a couple of action buttons in it. We hide the tab bar because it's odd to have this action bar above a tab bar both visually and when touching buttons (because it can be easy to mistap and activate a tab when an action button was the target or vice-versa).The problem occurs when we create one of these views. The view is defined via a UIViewController in an xib. If we create constraints from a subview (say, the bottom of a top level table view or the action bar itself) in the xib to the bottom of the safe area of the view controller's main view, the layout at runtime acts as though the tab bar is still visible even though it is hidden. So we have a space at the bottom of the screen that is the height of the bottom home button plus the tab bar height.After looking for solutions that didn't require specific checks for an iPhone X and iOS 11 (because iOS 10 doesn't have the issue), I relented and started trying anything that could work. If I create two constraints, one with a zero constant to the bottom safe area and one that forces the main view downward by the height of the tab bar, and then only make one of them active depending on what device and OS version is being run, it appears to work. Until it doesn't.The first layout of the screen on iPhone X will work, but if we then (for example) show a modal screen and then return to the first screen, the layout will be incorrect again. The bottom of the main view will go off the bottom of the screen.Uhg.
Replies
3
Boosts
0
Views
7.6k
Activity
May ’23
lamda versus lambda
anyone else notice this greek letter misspelled in the keycaps app? i thought i was spelling it wrong but maybe not?
Replies
2
Boosts
0
Views
1.4k
Activity
May ’23
Xcode 13/14 -- Interface Builder Forgets State
Whenever I switch away from a Nib file and then come back to it, Interface Builder "resets" its state. That is, the left-hand outlineView that shows the structure of an IB document collapses to a stupid "minimized" width and the canvas has scrolled away from the view/window I had selected before switching away from IB. This has been a constant issue in Xcode 13 and persists in Xcode 14 Beta 2. Is anyone else seeing this behavior? I have filed multiple Radars about it over the last year and not one has gotten a response (shocking, I know).
Replies
2
Boosts
0
Views
1.4k
Activity
May ’23
How Can I Disable Auto Layout?
I have some NSPanels that are not resizable, the App is not localized and and don't need Layout Constraints. Any time I edit an NSText field in the .xib, XCode 14.2 starts to report many errors: "Views without any layout constraints may clip their content or overlap other views." I spent a lot of time trying to make XCode stop reporting these warnings, but I can't. Sometimes quiting XCode or restarting my Mac will make these go away. According to XCode Help: "Auto Layout is enabled by default. To disable Auto Layout, choose View > Inspectors > Show File Inspector and deselect the checkbox for Use Auto Layout." Too bad there isn't any checkbox for Use Auto Layout in the file inspector for the .xib, the .panel's view or the NSText Field so I can't actually do this. The editor>Layout>Automatic menu item is disabled. Is there really any way to disable Auto Layout or has Apple decided to require it?
Replies
4
Boosts
0
Views
3.1k
Activity
May ’23
Override supported destination on xcFramework
Is it possible to display the screen same as the size of iphone on Ipad even if the app supports iPad. Want to prevent resize of screens on iPad for a library even though the app supports iPad. is that possible?
Replies
0
Boosts
0
Views
683
Activity
May ’23
Problem with Safe Area
Anyone knows how to solve this problem with safe area bottom??
Replies
0
Boosts
0
Views
429
Activity
May ’23
NSUnknownKeyException when connecting property IB
I am trying to integrate a UIKit view into my SwiftUI project using UIViewRepresentable as an intermediate. A TestViewVC.swift file was created containing just a simple IBOutlet: import Foundation import UIKit class TestViewVC: UIViewController { @IBOutlet weak var testLabel: UILabel! } A corresponding TestViewVC.xib file was creating containing just a single label centred on screen. The TestViewVC was then assigned as the File Owner's class. These are then displayed within the SwiftUI context through the use of a TestRepresentableView.swift and TestViewVC.swift class (shown below). //TestRepresentableView.swift import SwiftUI struct TestRepresentableView: UIViewRepresentable { func makeUIView(context: Context) -> UIView { // Load the XIB file and return its view let nib = UINib(nibName: "TestViewVC", bundle: nil) return nib.instantiate(withOwner: nil, options: nil)[0] as! UIView } func updateUIView(_ uiView: UIView, context: Context) { // Update the view here if needed } } //TestViewVC.swift import SwiftUI @main struct TestApp: App { var body: some Scene { WindowGroup { TestRepresentableView() } } } The app runs fine on debug however an NSUnknownKeyException is raised whenever label is connected to the IBOutlet. (Or any other outlet for that matter, even simply connecting the view results in the same error). Any idea of which this is happening?
Replies
1
Boosts
0
Views
649
Activity
May ’23
Xcode 11 Unknown class in Interface Builder file.
HiI recently updated to Xcode 11 GM seed. However I've noticed that the dreaded "Unknown class in Interface Builder file" is crashing my app. I haven't changed any class names or storyboards. Interestingly the app runs perfectly in teh simulator, but crashed on my phone.Here is what is being printed in the output window:MyAppName[9513:4230222] Unknown class _TtC10MyApp24SlideTableViewController in Interface Builder file.Could not cast value of type 'UIViewController' (0x1ebe282b0) to 'MyApp.SlideTableViewController' (0x104d05e08).MyAppName[9513:4230222] Could not cast value of type 'UIViewController' (0x1ebe282b0) to 'MyApp.SlideTableViewController' (0x104d05e08).I've deleted the class and recreated, removed the View Controller from the story board, made sure the view controller is references correctly as is the target, but the problem persists and I'm out of ideas.Is there a "reset" of the storyboard to reference the elements? Or some other way to resolve this?Many thanksCraig
Replies
7
Boosts
0
Views
26k
Activity
May ’23
Problem with NSTableView constraints
Hi, the problem is not dangerous to life, I don't want see the yellow button on top of the editor. 'Autoresizing Mask' is set to about 50 items, that works, except tableView, 10 warnings. The tableView has 10 columns of 20 pixels width, min 10 and max 100000. The ' Add new constraints' options are all grayed, so what ? In an other project a warning was set for arrayController, I don't like Auto Layout, the blue help lines are enough. My question is : How do i can suppress this warnings ? Kindly, Uwe
Replies
0
Boosts
0
Views
1.2k
Activity
May ’23
Could not find a storyboard named 'main' in bundle NSBundle
What does this error mean?"Could not find a storyboard named 'main' in bundle NSBundle"
Replies
2
Boosts
0
Views
17k
Activity
Apr ’23
iOS storyboards do not support target device type "mac".
When running my program on my mac using xcode getting /Users/suhaan/Documents/kivy-ios/weatherpsychic-ios/Storyboards/Launch Screen.storyboard: iOS storyboards do not support target device type "mac".
Replies
0
Boosts
3
Views
1.2k
Activity
Apr ’23
Where is the Preview function in Xcode Version 14.2 (14C18)?
Xcode 14.2 is really crap. I cannot find the Preview function as what I have in previous version. I cannot find this menu item:
Replies
0
Boosts
0
Views
656
Activity
Apr ’23