iPhone – Load UiView from NIB as another subview of UIView from NIB loading

The idea is basically:
Inside the myViewController NIB, I have a UIView as a subview, connected to the IBOutlet on the MyViewController class. I want to load the UIView subview from the NIB. subView also has a class associated with it. But the subview is not displayed. This is my job

On MyViewController.h

 @interface MyViewController: UIViewController {
IBOutlet SubView *subView; // this outlet is connected to an empty UIView on IB
}
@end

On MyViewController.m

-(id)init {
if ((self = [super init])) {
// load the main view
[[NSBundle mainBundle] loadNibNamed:@"myViewController" owner:self options:nil];
// load the sub view from another NIB
self.subView = [[[NSBundle mainBundle] loadNibNamed:@" subView" owner:self options:nil] objectAtIndex:0];
}
}

SubView.h is defined as:

@interface SubView: UIView {
}
@end

What am I doing wrong?

GianPac – shameless self-promotion, but I did a blog post about this a month ago . Feel free to ignore the code related to shadows.

http://nathanhjones.com/2011/02/20/creating-reusable-uiviews-with-a-drop-shadow-tutorial/< /p>

Also, I (thanks to several people for the advice) avoid having multiple view controllers on my’view’. The method outlined above allows you to accomplish this and still use IB to perform the layout/outlet.

The idea is basically:
Inside the myViewController NIB, I have a UIView as a subview, connected to the IBOutlet on the MyViewController class. I want to load from the NIB UIView subview. subView also has a class associated with it. But the subview is not displayed. This is my job

On MyViewController.h

@interface MyViewController: UIViewController {
IBOutlet SubView *subView; // this outlet is connected to an empty UIView on IB
}
@end

In MyViewController.m on

-(id)init {
if ((self = [super init])) {
// load the main view
[[NSBundle mainBundle] loadNibNamed:@"myViewController" owner:self options:nil];
// load the sub view from another NIB
self.subView = [[[NSBundle mainBundle] loadNibName d:@"subView" owner:self options:nil] objectAtIndex:0];
}
}

SubView.h is defined as:

@interface SubView: UIView {
}
@end

What am I doing wrong?

GianPac – shameless self-promotion, but I did a blog post about this a month ago. Feel free to ignore the code related to the shade.

http://nathanhjones.com/2011/02/20/creating-reusable-uiviews-with-a-drop-shadow-tutorial/

In addition, I (thanks to Personal suggestion) Avoid having multiple view controllers on my’view’. The method outlined above allows you to accomplish this and still use IB to perform the layout/outlet.

< /p>

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 1057 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.