Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to configure the subclassed UIView in interface builder(.xib) before it is shown?
    primarykey
    data
    text
    <p>In my application I've subclassed UIView and it has three ivars declared in .m file (2UIButton and an UITextField ). I use this object by drag the UIView from the objects library and convert them to my subclass. below is my implementation</p> <pre><code>@interface Prescriber()&lt;UITextFieldDelegate&gt; { UIButton *_addButton; UIButton *_lessButton; UITextField *_valueField; } @end @implementation Prescriber @synthesize value=_value,intValueofStrig=_intValueofStrig; - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code } NSLog(@"prescriber called"); return self; } /* // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. - (void)drawRect:(CGRect)rect { // Drawing code } */ -(void)layoutSubviews { if (!_addButton) { _addButton=[[UIButton alloc]init]; [_addButton addTarget:self action:@selector(addbuttonClicked:) forControlEvents:UIControlEventTouchUpInside]; [_addButton setBackgroundImage:[UIImage imageNamed:@"add1.png"] forState:UIControlStateNormal]; _addButton.layer.cornerRadius=5; } if (!_lessButton) { _lessButton=[[UIButton alloc]init]; [_lessButton addTarget:self action:@selector(lessButoonClicked:) forControlEvents:UIControlEventTouchUpInside]; [_lessButton setBackgroundImage:[UIImage imageNamed:@"Minus.png"] forState:UIControlStateNormal]; } if (!_valueField) { _valueField=[[UITextField alloc]init]; _valueField.delegate=self; } ///positioning the addbutton on left corner and right corner and position and textfield in the center } </code></pre> <p>I've done the configuring code in the -(void)layoutSubviews method as my -initwithFrame not get called as they are already in the xib file. what I want to know is ,Is it right to do our initialization in the -layoutSubViews as there is a chance for this method to get called another time. Or am I able to invoke the -viewDidLoad like delgate method for my subclassed View too?</p> <p>Edit:- It is possible by creating an IBOutlet but that way is a constraint for me.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload