interface-builder

Why are my UIView layer properties not being set when called within initWIthCoder:(NSCoder *)aDecoder?

有些话、适合烂在心里 提交于 2019-12-22 03:58:57
问题 I have a custom View class built which subclasses UIView. This view is loaded through a nib file in the ViewController via: [[NSBundle main] loadNibNamed:@"MyCustomView" owner:self options:nil]; Inside MyCustomView.h (which correctly hooked up in IB as the Main Views class) I have some subview properties linked: @interface MyCustomView : UIView <UITextFieldDelegate> { .... @public UIView *backgroundLayer; // a subview of the Main View inside the nib .... } @property (nonatomic, retain)

Attributes Inspector: how to use “Stretching”

╄→尐↘猪︶ㄣ 提交于 2019-12-22 01:38:13
问题 What are the numbers in the Stretching box in the View sub-box Interface Builder's Attributes Inspector? (as a side question - I suppose a respectable company such as Apple would have actually released documentation for its tools, as opposed to letting developers just guess everything; so, where's this documentation?...) 回答1: This blog post Karol seems to explain it pretty well. - http://macoscope.com/blog/stretchable-images-using-interface-builder/ Stretching properties are pretty simple (I

Storyboard: How do I let Xcode automatically update frames when I change layout constraints?

余生颓废 提交于 2019-12-22 01:38:07
问题 I have seen a WWDC 2014 video (What's new in Interface Builder) where the presenter uses Storyboard and changes the height of a table view cell prototype within a table view controller (at around 7m30s). I see all the subviews of that cell resize as he drags the height-handle on the cell. This is great, because now you can see how your layout constraints behave in different scenarios very quickly. He doesn't explain how he does it. Because when I drag the height-handle of a table view cell

Any-Any size class ignored for ios7

混江龙づ霸主 提交于 2019-12-21 10:48:38
问题 I'm developing for both iOS7 and 8 iPhone. Since iOS7 doesn't support compact-height size classes, I thought the consensus way to go about this was to use the any-any size class for landscape iPhone layouts, and use portrait compact-width regular-height (cWrH) size class for portrait iPhone layouts. I set a constraint on a view in any-any, then modify a constraint constant in cWrH to be specific to that size class. However, iOS7 device as well as Xcode preview ignores the any-any constraint,

No content attribute for UITableView in .xib

孤者浪人 提交于 2019-12-21 10:48:05
问题 (XCode 4.2, iOS 5) In order to reuse a tableview (with a navigation bar and edit/add buttons) I created a UITableViewController subclass with it's own .xib . However, when I add a UITableView to my .xib 's main view the content attribute (which I want to set to dynamic prototypes) it doesn't show up. It just shows the sample content ( California: Brea, Burlingame, ... ). When I add a UITableView in my main storyboard the content attribute does show up. What is the issue? 回答1: For people

Xcode auto layout constraints - why defaulting to negative padding?

不想你离开。 提交于 2019-12-21 09:08:32
问题 I am simply adding a UIView into the main view of a view controller. I want the height to always be 64px, but the width to stretch to the width of the screen. However, when I go to add constraints, the left and right padding default to -16, even though the view is stretched all the way across its parent view. Even if I set these back to 0, when I run the app the -16 padding is added back in. What is going on here? 回答1: Uncheck "Constrain to margins" checkbox in the pin menu (the first image

Xcode auto layout constraints - why defaulting to negative padding?

非 Y 不嫁゛ 提交于 2019-12-21 09:08:11
问题 I am simply adding a UIView into the main view of a view controller. I want the height to always be 64px, but the width to stretch to the width of the screen. However, when I go to add constraints, the left and right padding default to -16, even though the view is stretched all the way across its parent view. Even if I set these back to 0, when I run the app the -16 padding is added back in. What is going on here? 回答1: Uncheck "Constrain to margins" checkbox in the pin menu (the first image

Binding a custom NSView: Does it demand creating an IBPlugin?

妖精的绣舞 提交于 2019-12-21 07:31:18
问题 I have created a subclass of NSView to draw an image as a pattern: @interface CePatternView : NSView { NSImage* image; id observableObjectForImage; NSString* keyPathForImage; } @end I implemented the following to expose bindings: + (void)initialize { // Expose the "image" binding to IB. [self exposeBinding:@"image"]; } - (Class)valueClassForBinding:(NSString *)binding { if([binding isEqualToString:@"image"]) return [NSImage class]; return nil; // Unknown binding } Unfortunately, the image

UIView shadow and InterfaceBuilder

时光怂恿深爱的人放手 提交于 2019-12-21 07:28:36
问题 I want to add a drop shadow using CALayer to a UI(Image)View. The following code works generally fine previewImage.layer.shadowColor = [[UIColor blackColor] CGColor]; previewImage.layer.shadowOffset = CGSizeMake(1.0f, 1.0f); previewImage.layer.shadowOpacity = 1.0f; previewImage.layer.shadowRadius = 8.0f; However, this only works if I create that view programmatically and add it as a subview to my main view. When that view is set up in InterfaceBuilder and defined as an IBOutlet UIImageView

Center Multi-Line Text on UIButton using IB

让人想犯罪 __ 提交于 2019-12-21 07:04:33
问题 How do you center text line-by-line in a UIButton using Interface Builder? I am scouring the options and just don't see it. Here's the button: 回答1: You can't set the text to be centered in your nib. But you can change the alignment in your code: - (void)viewDidLoad { [super viewDidLoad]; self.myButton.titleLabel.textAlignment = UITextAlignmentCenter; } 回答2: I know this is an old question, but I came across it in my own attempt to center the multi-line text of a UIButton in IB. What I found is