nib

Loading custom UIView from nib, all subviews contained in nib are nil?

末鹿安然 提交于 2019-12-17 17:30:03
问题 I have a custom UIView object with a nib that defines the view/subview layout. My outlets are connected, and when I init the object from initWithFrame: everything is in order. The problem I'm having is when I'm using IB to embed the UIView into another nib; the custom UIView appears, but none of the subviews it contains appear - in fact their symbols all resolve to nil. I have a very minimal initWithCoder: and awakeFromNib: implementation (just does logging) and my understanding is that as

NSViewController and multiple subviews from a Nib

你。 提交于 2019-12-17 17:28:30
问题 I'm having a difficult time wrapping my head around loading views with Interface Builder and NSViewController. My goal is to have a view which meets the following description: Top bar at the top (like a toolbar but not exactly) which spans the entire width of the view, and a second "content view" below. This composite view is owned by my NSViewController subclass. It made sense to use Interface Builder for this. I have created a view nib, and added to it two subviews, laid them out properly

Why won't my awakeFromNib fire?

蹲街弑〆低调 提交于 2019-12-17 09:49:48
问题 I am starting to move more of my view hierarchy construction to IB. I have a nib file called "AlignmentViewController.xib" in which I set up my view hierarchy with AlignmentViewController as the files owner. This works fine. One of the methods I remain fuzzy on is awakeFromNib. In the follow code snippet of AlignmentViewController I add the single additional method awakeFromNib. However, it does NOT get called: - (void)awakeFromNib { NSLog(@"AlignmentViewController - awakeFromNib"); [super

How to assign an identifier to a UIViewController from the MainStoryboard?

…衆ロ難τιáo~ 提交于 2019-12-14 03:58:46
问题 Before I used to allocate and initialize a view controller using initWithNibName, where the parameter for the Nib name is simply the name of the xib/nib file. However, with the way Xcode/IB works with Storyboards now, I'm not sure what I need to do to initialize a view controller class with it's respective xib/nib. In my storyboard i have created the view controller and referenced it (from another view controller) and specified it as a Popover type. Any ideas how this is accomplished? Thanks.

Subclasses of UIButton loaded from nibs are not initialized properly

时光毁灭记忆、已成空白 提交于 2019-12-14 03:47:19
问题 I have a very simple subclass of UIButton: @interface MyButton : UIButton @end @implementation MyButton - (id) initWithCoder:(NSCoder *)decoder { if (!(self = [super initWithCoder:decoder])) return nil; NSLog(@"-[%@ initWithCoder:%@]", self, decoder); return self; } @end In Interface Builder I add a UIButton, set its button type to Rounded Rect and its class identity to MyButton . When running, I have the following log: -[<MyButton: 0x5b23970; baseClass = UIButton; frame = (103 242; 114 37);

How to change dynamically the xib of a UIVIewController

别来无恙 提交于 2019-12-13 12:33:48
问题 I have an UIVIewController "controller1" for instance. This controller is instanciated with initWithNibName... with "file1.xib". I want to dynamically change the xib file of my "controller1" to "file2.xib" To resume : "controller1" <-> "file1.xib" and I want to dynamically have : "controler1" <-> "file2.xib" How can I do this ? Hope I was clear. 回答1: When you want to change views in a UIViewController just just use this code: NSArray *nibObjs = [[NSBundle mainBundle] loadNibNamed:@"file2"

Intercept/Programmatically set IBOutlet properties

六眼飞鱼酱① 提交于 2019-12-12 20:07:49
问题 Question: Is there any way that I could set IBOutlet properties programmatically and in an automated way (i.e. without hard-coding the properties to be set)? Maybe there is some "IBOutlet setting" routine that I could intercept with my own specialized code? Background: The problem leading to the question above originates from the fact that "IBOutleted" size constraints (width and height) are not being set when running the following method (it's a method for replacing a "placeholder" view from

How do you handle memory management of outlets in the iPhone SDK

允我心安 提交于 2019-12-12 09:29:06
问题 Since KVC is used to set outlets on the iPhone, there are 2 methods (that I know of) to make sure you've properly handled memory management. Specifically, I am referring to this article written by Aaron Hillegass. My question is which method do you use and what is your reasoning? Release all your outlets in dealloc and viewDidUnload (Make sure you set them to nil in viewDidUnload.) Make your outlets weak references Personally, I am leaning towards using weak references as it seems cleaner.

Views are mirrored in RTL languages

戏子无情 提交于 2019-12-12 07:47:16
问题 When setting your device to a Right-To-Left language, iOS reverses the order of items. For example in a UITableViewCell set with Auto-Layout: I have an avatar image on the left and some text aligned right from it that fills up the rest of the cell. In Arabic my avatar is on the right and my label is on the left. Is there a way to prevent iOS from doing this on certain views, or is there a general setting defining whether or not it can be reversed? 回答1: For Xcode6 and iOS8 you can uncheck

Why does this init method when loading a nib return an object out of scope?

喜欢而已 提交于 2019-12-12 02:48:57
问题 Why does this init method return an object out of scope? Using XCode 4.2, base SDK of 4.3, and ARC, I'm trying to load an UIView from a nib (not a UIViewController). I need to not use a UIViewController at all in the process. After reading this answer to an S.O. question here, it looks like it can be done: How to load a UIView using a nib file created with Interface Builder (The answer by user "MusiGenesis" describes the process) I created a sub-class of UIView with a single label: @interface