Interface Builder

RSS for tag

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

Posts under Interface Builder tag

97 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Binding to Shared User Defaults might fail in Xcode storyboards
While binding to the Shared User Defaults in .xib files is very easy I had hard times to achieve application wide preferences in projects based on storyboards. The behavior is a bit strange/unexpected and even in Xcode 15.4 it seams not to be completely solved. Issue is that IB only creates a single instance of a Shared User Default controller for the first scene, where it was requested and linking to this instance from other scenes offers no functionality. Even worse IB suggests this as first binding proposal. Here an example to deal with this issue. add slider and label to view of ViewController in IB storyboard add MenuItem to windows menu in the Application Scene When running the app this menu item remains disabled as no action is connected bind value of the created menu item to the Shared User Defaults with Model Key Path: “showTerminal“ This creates a Shared User Defaults Controller instance that we use later. Now running the app the menu item is enabled and the checkmark toggles each time add a checkbox to the view add a User Default Controller to the View Controller Scene This must be repeated for any further Window- or View- Controller scene where a binding to the user defaults is required. bind the checkbox to the newly added User Defaults Controller (but not the Shared User Defaults Controller) keeping the suggested Controller key values and set the Model Key Path to “showTerminal“ as above now bind the slider and the label to the same User Defaults controller using an identical Model key If accidentally bound to the Shared User Defaults Controller (this is what IB suggests) no functional binding will take place! Register the defaults early (before the nib is being loaded) to set default values like for example: class AppDelegate: NSObject, NSApplicationDelegate { override init() { super.init() UserDefaults.standard.register(defaults: [ "first": 0.0 , "showTerminal": false ] ) } … } [https://github.com/MissingManual/UserDefaultsBindingsInStoryboard] ATTENTION: Suggestion is, to create the first Defaults Controller as a Shared User Defaults Controller inside the Application scene. Somehow Xcode remembers settings of the Shared User Default Controller and otherwise bindings might fail. MESSAGE: Never bind to the “Shared User Default Controller“ but to individually created “User Default Controller“ for every scene, unless it is the very first time. Alternatively you can set a let variable as @objc let defaults = UserDefaults.standard for example in each ViewController and then bind to this by Bind to: ViewController Controller Key: Model Key Path: defaults.
0
0
38
22h
IDE generated *varname problem
When Xcode IDE inserts IBOutlet or autocompletes method signatures, it places the * char next to the var name: @property (weak) IBOutlet NSButton *aButton; - (NSString *)someMethod:(NSString *)param1 { } But my convention is put the * char right after the type name: @property (weak) IBOutlet NSButton* aButton; - (NSString*)someMethod:(NSString*)param1 { } Is there anyway to tell Xcode to follow my convention?
0
0
64
2d
Unable to add fonts to XCode project
Added fonts to MAC and added to Xcode project but fonts are not available in project. Fonts are listed in the Copy Bundle Resources. Fonts are added to Fonts provided by application (Listing dissapears whenever I leave the 'Info' page. Font spelling is correct and double checked. Fonts are listed in project navigator. Fonts do not show up when the lists runs in the console. This same scenario to place when trying to add a different fonst as well. Your help would be appreciated.
0
0
257
2w
Debug mysterious window resize?
I am unfortunately faced with a large legacy code base in which Storyboards are heavily used. Now, for some reason, the entire app window is resized if a certain View Controller becomes visible. The issue: Apparently, there aren't any conflicting layout constraints (no LAYOUT_CONSTRAINTS_NOT_SATISFIABLE errors are raised on display of the view controller). There are also no calls to setFrame on the corresponding window. So, how do I debug this? Capturing the view hierarchy didn't provide any helpful insights, and ideally I could just force the window to not resize (due to possible constraint errors). Is there any way to achieve something like this? If not, how can I go about debugging this? Any help on this would be greatly appreciated.
0
0
169
2w
Asking about Viewcontroller presenter
I have a ViewController A that need to present in Viewcontroller B. But before the VC A is presented, user pushed to Viewcontroller C and the VC A still show on C. How can it possible? In my point of view, I think the VC B will not show because the VC A is hided. Anyone can help me with this?. Many thanks
0
0
142
2w
Hello Devs I would need your help for Time estimate.
The devs really hate this things, but as a project manager I need to know the time estimates. So in development favour I really want to know the time estimate to setup and XCode project, considering project as an average case (includes complexity). So I can really know hpow much time do they actually take or they are just giving over estimates.
1
0
310
Apr ’24
How can I create a .ipa file ??
Hello everyone!! I am writing to inquire about the procedures for testing an application I am developing for iOS devices. The application has been developed using Flutter, and I would like to make it available for testing on my colleague's iPhone, who serves as our QA tester. Currently, my account on the App Store is free, and I would like to ensure proper testing before proceeding with deployment to the Apple Store. As the application is quite large, I am unable to provide it in debug mode on the QA tester's device. Therefore, I would like to enable them to use the application on their personal device for a few days to provide comprehensive feedback on performance and features. Could you please provide guidance on how to proceed with this beta testing process? I am committed to adhering to all of Apple's guidelines and policies to ensure a high-quality user experience. I would be very grateful if anyone could help me out on this, Thank you.
2
0
344
Apr ’24
layoutAttributesForItem(at indexPath:) never gets called on UICollectionViewLayout subclass
Hi! I've got a custom UICollectionViewLayout which has its cells and two supplementary kind of views scattered all over randomly within its bounds. It should be a calendar month view with day of week labels on top, week numbers on the left (supplementary views) and day cells in the middle (items). So far I tracked down that the layoutAttributesForItem(at indexPath:) and layoutAttributesForSupplementaryView(ofKind elementKind:, at indexPath:) are not getting called. Which gives them a reason not to be placed where they should be. layoutAttributesForElements(in rect: ) gets called indeed and the returned value is also OK: override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { super.layoutAttributesForElements(in: rect) var arr = [UICollectionViewLayoutAttributes]() arr.append(contentsOf: AllAttributes.filter({ (Item:UICollectionViewLayoutAttributes) -> Bool in (collectionView!.numberOfSections) > Item.indexPath.section && rect.intersects(Item.frame) })) return arr //47 long array of UICollectionViewLayoutAttributes } In IB the Collection View is specified to be Custom Layout and the respective subclass is specified there. I inspected the official example code here: https://developer.apple.com/documentation/uikit/views_and_controls/collection_views/layouts/customizing_collection_view_layouts The only diffrerence I see is that the example uses UICollectionViewController, which is specified to be Flow Layout in IB, and then the UICollectionView is re-instantiated in code as custom during viewDidLoad. Could that really make a difference? This solution would not be too convenient for me, as I have also other controls on my Controller View. Any help would be appreciated.
0
0
362
Apr ’24
Why unwind method doesn't work now in UIKit?
Hello everyone, I'm facing a problem that I can't connect the button to the unwind segue. I have made a simple application with three controllers. The unwind segue code is located in Table View Controller. @IBAction func unwindToTableViewController(_ unwindSegue: UIStoryboardSegue) { let sourceViewController = unwindSegue.source } A first segue has been implemented from the Add button on Table View Controller to the View controller. It is a Push type. There is a Save button as Bar Button Item in the View Controller. When I try to drag a connection from Save button to the Exit icon of the View Controller, the context menu does not open indicating the unwind segue. Instead, a context menu appears with different types of segues. At the same time, if I just click the Exit icon, a context menu appears where the unwind method is visible. Just in case, I re-read the documentation again and looked at examples of using the unwind method. There is no mention of this problem anywhere. The only hypothesis left is that this problem is related to the new version of Xcode. The example of application given here was created in XCode 15.3. I have tested the same application on another computer, where the version of Xcode is 13.4.1. There, when I try to drag a connection from the Save button to the Exit icon, a context menu appears with the name of the unwind method. But the problem didn't end there because after the connection is established, the button does not work and the View Controller does not dismiss. I can't understand why this is happens. It worked before. Is that one a bug or the feature? How to fix it? Any ideas would be greatly appreciated!
1
0
411
Mar ’24
iOS size classes like Regular, compact, Any
I am new to using iOS Objective-C size classes like Regular, compact, Any. I found that Compact size classes are anything less than ~640 pts and Regular size classes are anything larger than ~640 pts . Is that correct for both iphone and ipad? How can I use size class to make an image full screen on all the iphone and ipad devices and on any orientation? How many images will I need? Any help and insight is greatly appreciated!
0
0
592
Mar ’24
UICollectionView vision becomes small for a few seconds when cell tap
UICollectionView vision becomes small for a few seconds when cell tap See image [Before] [After] In practice, when I press on the cell (tap) it should tag the element, on iOS 17 it works perfectly, on iOS 15.8.1 however it has the ugly effect of shrinking the entire content of the collectionview for a few seconds. Can anybody help me ? I don't know where to look anymore
0
0
321
Mar ’24
UIKit Collection View inside TableViewCell
I have a collelctionview inside a tableview cell in UIKit. The cells of the collectionview have dynamic content and their height and width depends on the content, which decides the height of the collectionview inside tableview cell. I have used many methods to calculate height correctly at first and as I scroll the tableview or perform any button action, the height does not gets correctly to me. Please provide a good solution or replacement for this problem.
0
0
410
Mar ’24
Intents UI Extension
I have successfully created the Intents UI Extension file for the wallet, obtained the requisite certificate, and adhered to the MeaWallet guidelines. Additionally, I have generated a sandbox login ID and successfully logged into the simulator using the sandbox login ID. In an attempt to integrate the Intents UI Extension file into an existing project, I followed these steps: Debug -> Attach to Process by PID or Name. Subsequently, I conducted a search for the Intents UI Extension file name, selected the appropriate file, and clicked the attach button. However, Xcode is currently displaying 'waiting for attachment.' Despite these efforts, I encountered an issue where the wallet extension controller is unable to access the application when attempting to run it.
0
0
478
Feb ’24
SFML
Hello Folks! I'm new to Xcode and I'm trying to create a simple 2D-Game with c++ and I found out, that SFML offers a nice tool to create a game engine. Now my purpose is to develop tools for studying and I'm trying to link SFML with Xcode. Since I already was successful in creating a pop-up window via the terminal I believe I can handle to do it with Xcode. I tried the following: I created a new SFML project in Xcode with the same Main.cpp file. I went to the build settings and changes the Header-Path to the SFML-Include folder and the Library-Path to the SFML-lib folder. I also linked the binaries with the libraries in the build phase. When I run the script Xcode told me, that the build was successful and the app tried to open the window (It jumped around and appears in the strip. But I also got an error message, that the dynamic libraries couldn't load. It would be very nice, if someone could help me with my issue. Happy to hear from you, kind regards Jeremy
0
0
508
Feb ’24