Hi All,
I am going to give, making my own Controls and see how successful things turn out.
The one I am creating now is pretty simple, it's a UIView that has a Label, Text Field & Button.
I have done this by making a XIB file with the associated Header and Implementation files.
At this point, I have subclassed it as a UIView and the following illustrates how I have done this:
NameView.h
NameView.m
In the applications code, I am calling the control with:
When running the application, I do not see errors nor do I see the expected NameView control appear.
I am now wondering if I have subclassed incorrectly. Should I be using UIControl instead of UIView in the code for the control, or have I make a mistake elsewhere??
Pete
I am going to give, making my own Controls and see how successful things turn out.
The one I am creating now is pretty simple, it's a UIView that has a Label, Text Field & Button.
I have done this by making a XIB file with the associated Header and Implementation files.
At this point, I have subclassed it as a UIView and the following illustrates how I have done this:
NameView.h
Code:
#import <UIKit/UIKit.h>
@interface NameView : UIView
@property (strong, nonatomic) IBOutlet UIView *view;
@end
NameView.m
Code:
#import "NameView.h"
@implementation NameView
@synthesize view = _view;
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if(self)
{
[self setup];
}
return self;
}
- (void)setup {
[[NSBundle mainBundle] loadNibNamed:@"NameView" owner:self options:nil];
[self addSubview:self.view];
}
@end
In the applications code, I am calling the control with:
Code:
NameView *nameView = [[NameView alloc] initWithFrame:CGRectFrame(20.0, 75.0, 633.0, 124.0)];
[self.view addSubview:nameView];
When running the application, I do not see errors nor do I see the expected NameView control appear.
I am now wondering if I have subclassed incorrectly. Should I be using UIControl instead of UIView in the code for the control, or have I make a mistake elsewhere??
Pete