interface-builder

Can NSCollectionView autoresize the width of its subviews to display one column

别说谁变了你拦得住时间么 提交于 2019-12-18 04:12:05
问题 I have an NSCollectionView that contains a collection of CustomViews . Initially it tiled the subviews into columns and rows like a grid. I then set the Columns property in IB to 1, so now it just displays them one after another in rows. However, even though my CustomView is 400px wide, it's set to autoresize, the NSCollectionView is 400px wide, and it's set to 1 column, the subviews are drawn about 80px wide. I know I can get around this by calling: CGFloat width = collectionView.bounds.size

Make UIView fill containing view using auto layout in Interface Builder instead of code

≡放荡痞女 提交于 2019-12-18 03:57:06
问题 How do I use auto-layout to make a child view fill its parent, or at least anchor all its edges to the parent view's edges? I am using all four vertical and horizontal constraints in "Spacing to nearest neighbour", but when I run the app on a 3.5" device, the height of the view has not been automatically adjusted from 568 to 480 as expected. 回答1: Pin the top space to superview, bottom space to superview, leading space to superview and trailing space to superview. Then set edit the constraints

swift protocol, IBOutlet property cannot have non-object type

浪尽此生 提交于 2019-12-18 03:10:13
问题 I would like to wire up a custom swift delegate in IB. The delegate is an object that implements a certain protocol in swift. protocol ThumbnailTableViewCellDelegate { func cellWasTouched(thumbnail: Bool, cell: UITableViewCell) } class ThumbnailTableViewCell: UITableViewCell { @IBOutlet var thumbnailTableViewCellDelegate: ThumbnailTableViewCellDelegate? } unfortunately, the compiler complains with: error: 'IBOutlet' property cannot have non-object type 'ThumbnailTableViewCellDelegate'

Interface Builder Lock Item Positions?

ぃ、小莉子 提交于 2019-12-18 03:04:32
问题 When working with UI items in Interface Builder is there any way to lock an item's position once you are happy with its placement? I only ask as I keep slightly dragging items when selecting them for edits resulting in having to go back and tweak positions. 回答1: Select Identity Inspector ( Cmd 4 ) and select "All Properties" or "Localizable Properties" in the Lock menu. 回答2: In Xcode 4.2 it is under "Show the Identity Inspector", there under Identity -> Lock -> All Properties See Image: every

Loading a UIView subclass from NIB size issues

纵然是瞬间 提交于 2019-12-18 02:42:33
问题 I have a subclass of UIView that needs to calculates it's height according to it's width. When created in code everything works. However when I try to create the view in Interface builder, and although I override all related methods, I can't get the size of the view set in interface builder. - (id)initWithCoder:(NSCoder *)aDecoder { NSLog(@"init with coder before super width %d",super.frame.size.width); // returns 0 self = [super initWithCoder:aDecoder]; NSLog(@"init with coder after super

How to access User Defined Runtime Attribute from the 'sender' object?

老子叫甜甜 提交于 2019-12-18 02:38:07
问题 I have a UIButton in a Storyboard scene. The button has a User-Defined-RunTime-Attribute 'type'(String) configured. When pressed the button calls -(IBAction)pressedButton:(id)sender Will I be able to access the User-Defined-RunTime-Attribute from 'sender'? 回答1: Yes: -(IBAction)pressedButton:(id)sender { id value = [sender valueForKey:key]; } Note that you cannot use a User Defined Run Time attribute, unless you subclass UIButton and add it as a strong property , for example @interface

Designing labels/text views with custom fonts in Interface Builder

对着背影说爱祢 提交于 2019-12-18 00:19:27
问题 I am currently working on an iPhone project in which all labels/text views etc. should appear with a custom font (I'm using Xcode 4.2.1). I have done some research on this, and the only solution seems to be adding the font files to the project, editing the info.plist file appropriately and setting the font programmatically (i.e. by outlets or by subclassing the relevant views). In any case, these approaches won't lead to the interface builder displaying the text with the custom font (it will

Designing in landscape with Storyboards

て烟熏妆下的殇ゞ 提交于 2019-12-17 23:03:26
问题 Is it possible to design interfaces in landscape with Interface Builder? Others with the same question apparently were able to do so with an arrow at the top right of any selected view, but I see no such arrow. A picture would be helpful. (Note: I am using storyboards, not xibs.) 回答1: Select the window in the storyboard, and open its Simulated Metrics property page (upper-right corner, an icon that looks like a shield next to the ruler icon). If the Simulated Metrics group is collapsed,

Design Pattern: Builder

泪湿孤枕 提交于 2019-12-17 22:45:45
问题 I have looked for a good example of a Builder pattern (in C#), but cannot find one either because I don't understand the Builder pattern or I am trying to do something that was never intended. For example, if I have an abstract automobile and abstract builder methods to create car parts, I should be able to send all 30 of my choices to the Director, have it build the pieces I need, then build my automobile. Regardless of which car, truck, semi, etc. produced, I should be able to "drive" it in

How to programmatically replace UIToolBar items built in IB

旧巷老猫 提交于 2019-12-17 22:25:46
问题 I have a toolbar with various image buttons, created in Interface Builder. I'd like to be able to programmatically replace one of the buttons with an activity indicator when pressed, and then put back the original button but change its color from white to yellow when the activity completes. Is this possible with an IB built toolbar or must I look at building the whole toolbar programmatically and custom views? 回答1: Here is an example of what I did in a similar situation. I wanted to build the