Reputation: 335
The problem is View is loaded but the inner elements are not loaded or did not appear why?
and the corresponding .h
is:
#import <UIKit/UIKit.h>
@interface DownloadView : UIView
@property (strong, nonatomic) IBOutlet UIView *view;
@property (weak, nonatomic) IBOutlet UILabel *downloadFilename;
@property (weak, nonatomic) IBOutlet UILabel *downloadpercentage;
@property (weak, nonatomic) IBOutlet UIProgressView *downloadprogressBar;
@property (weak, nonatomic) IBOutlet UIButton *downloadCancel;
@end
.m
file is:
#import "DownloadView.h"
@implementation DownloadView
-(id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self){
[[NSBundle mainBundle] loadNibNamed:@"DownloadView" owner:self options:nil];
[self addSubview:self.view];
}
return self;
}
-(id) initWithCoder:(NSCoder *)aDecoder{
self = [super initWithCoder:aDecoder];
if(self){
[[NSBundle mainBundle] loadNibNamed:@"DownloadView" owner:self options:nil];
[self addSubview:self.view];
}
return self;
}
The calling file is:
polygonView = [[DownloadView alloc]initWithFrame:CGRectMake(0, height-170, width, 100)];
polygonView.downloadFilename.text = @"Initiating Download...";
[polygonView.downloadprogressBar setProgress:0];
polygonView.downloadpercentage.text = @"0%";
[window addSubview:polygonView];
What is the Problem ?
Upvotes: 1
Views: 398
Reputation: 7113
Unfortunately you can't create custom UIView like this, it will not work. I use different way for reusable custom components which is:
Upvotes: 1