title: loadNibNamed vs. initWithFrame dilemma for setting frame's height and width
body: <p>I created a UIView subclass associated with .xib file. This UIView subclass is to be used in a UIViewController. In the controller, I think there are two options how we instantiate the UIView subclass:</p>
  
  <pre><code>MyUIView *myView=[[MyUIView alloc] initWithFrame:aRect];
  </code></pre>
  
  <p>and</p>
  
  <pre><code>MyUIView *myView = [[[NSBundle mainBundle] loadNibNamed:@"MyUIView" 
                                                    owner:self 
                                                  options:nil] lastObject]; 
  </code></pre>
  
  <p>I prefer the first approach or its variants that allow me to perform custom initialization. The only problem is that I have to specify a frame's rect, which was already specified in .<code>xib</code> (I mean frame's height and width of <code>MyUIView</code>). Yes, I can hardcode it again in <code>aRect</code>, but this is tedious to maintain (e.g., when I change position of UIs in .xib, I have to update <code>aRect</code>, too).</p>
  
  <p>So the second approach should come into mind as the frame rect is automatically set. The remaining problem is I cannot customize the initializer (say, I want to pass extra parameters during initialization).</p>
  
  <p>What's your preference? Which one is better in your opinion?</p>
  
  <p>EDIT1:
  Inspired by sergio's answer, I came out with this workaround:</p>
  
  <pre><code>// In MyViewController.m
  MyUIView *myView=[[MyUIView alloc] initWithFrame:CGRectMake(x, y, 0.0, 0.0)];
  
  // In MyView.m
  - (id)initWithFrame:(CGRect)frame
  {
      if (self = [super initWithFrame:frame]) {
          self = [[[NSBundle mainBundle] loadNibNamed:@"UnmovableTagView" 
                                                owner:self 
                                              options:nil] lastObject]; 
          [self setFrame:CGRectMake(frame.origin.x, 
                                    frame.origin.y, 
                                    [self frame].size.width, 
                                    [self frame].size.height)]; 
          // frame's width and height already determined after 
          // loadNibNamed was called
         ...
      }
      return self;
  }
  </code></pre>