interface-builder

How to connect a button to a method on Mac OS X

烂漫一生 提交于 2019-12-12 10:50:48
问题 I am used to programming for the iPhone. There, I would connect a button to an action, and then a method by creating the method like so: -(IBAction) DoStuff{…} . Then I would make an outlet for the button, and then the actual button in Interface Builder. I would then connect the button to the outlet, and then connect the button to the action by clicking on the circle next to Touch Up Inside and drag it over to File's Owner and select my action. I am new to programming for the Mac, so I tried

Can't change custom class of UIButton to GIDSignInButton

旧城冷巷雨未停 提交于 2019-12-12 10:33:40
问题 I'm trying to add Google sign in functionality to a custom button, and I'm following this tutorial. It's telling me to select the button, and set its class as GIDSignInButton , then add this code: @IBOutlet weak var signInButton: GIDSignInButton! . However, it doesn't let me set the class to GIDSignInButton . When I type it in and press enter, the field just clears. 回答1: The workaround is open the storyboard in text mode and put it directly. When you return to the interface builder it will

Instantiating a UIView from a XIB file with itself as the file's owner?

半腔热情 提交于 2019-12-12 09:56:25
问题 Let's say I have a XIB file (MyView.xib) containing a single root UIView whose class is some custom UIView subclass (MyView). I want to create an instance of MyView (in code) from the XIB file but I also want the file's owner to be the instance of MyView itself (so that I can link IBOutlets from the XIB to the code). In other words, MyView is the class of the root view in the XIB and it's also set as the file's owner class. I tried something like this inside the MyView implementation: - (id

Can not connect custom protocol delegate from storyboard in Xcode 6.1

二次信任 提交于 2019-12-12 09:49:50
问题 I just upgraded my mac to 10.10 and Xcode to 6.1, found a strange thing which about storyboard, my case is using a swift project, can not connect custom protocol delegate from storyboard anymore. the old connected which comes with old version of Xcode is fine, but I can not connect any new delegate anymore. even I can not reconnect the old one once I removed the connected. Does anyone occur this situation ?? ============================== Updated ============================== View Class

When to use InterfaceBuilder to build views?

大城市里の小女人 提交于 2019-12-12 09:46:39
问题 Going thru both the extensive online documentation AND the various code samples in the dev center I am perplexed. Apple's recommends to ALWAYS use IB when creating your views, and yet, in many of the code samples, views are created entirely in code (initialized in the loadView method of the viewController). Is there a 'best practice' as to when you should use IB as opposed to code to create your views? 回答1: There are no hard and fast rules, but in general, the more complex a view is, the more

Setting masked corners in Interface Builder

大城市里の小女人 提交于 2019-12-12 09:37:42
问题 What type of value is [.layerMaxXMinYCorner, .layerMinXMinYCorner] ? Is it possible to set this parameter on a View in Interface Builder? I know how to set layer.borderWidth , layer.borderUIColor and layer.cornerRadius in the Identity Inspector, but I can't figure out the right Type and Value to use for masked corners. Thanks! Jake Update: here are the integer values for each combination (in terms of which are rounded): 0: no rounded corners 1: top left 2: top right 3: top left & right (both

What's the best way to handle landscape/portrait differences in IB?

谁说我不能喝 提交于 2019-12-12 08:34:07
问题 I have a view that supports landscape and portrait viewing, with the controls all moving around when you switch from one to the other. I'm currently doing this by setting the .center of each one of my controls when the user rotates the phone. The problem is that this is tedious, and requires a lot of code, and seems to defeat the purpose of using Interface Builder in the first place. My question is: is there a way in Interface Builder for one view to support multiple looks (one for landscape

Why does Apple recommends to create modal navigation controllers programmatically?

♀尐吖头ヾ 提交于 2019-12-12 07:50:37
问题 "When presenting a navigation controller modally, it is often simpler to create and configure your navigation controller object programmatically. Although you could also use Interface Builder to do so, doing so is generally not recommended." If fact, because my navigation controller is simple, I would rather customise the view in IB! 回答1: While I don't know the exact reason, this is my shot at it: When creating the controller programmatically, you need only a few lines of code, in fact, in

Center UI elements in view with autolayout

浪子不回头ぞ 提交于 2019-12-12 05:54:50
问题 How do you use Autolayout to make a UI Element centered left-to-right when in both landscape and portrait mode? Can you have variables in autolayout? 回答1: If you are using Interface builder to create & set position of your view, Select your View & do as the screenshot suggests below. After that, click on "Add constraint" & you are done. This is just to set your view in horizontal centre. But you have to still add some more constraints. They are: Height Width Distance from top/bottom layout

Xcode: TabBar not showing in Interface Builder

随声附和 提交于 2019-12-12 05:11:49
问题 Interface Builder: I have a TabBarController connected to three different scenes. Every scene starts with a NavigationController and then has some different ViewControllers . The problem now is, that the Interface Builder is not longer showing the TabBars in the different scenes, expect in the TabBarController . I can still access the TabBarItems in the Document Outline and the app runs as expected, but it confuses me. Every scene is refactored to its own Storyboard, in case that matters.