问题是View已加载,但内部元素未加载或未出现原因?
和相应的.h
是:
#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
文件是:
#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;
}
调用文件是:
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];
问题是什么?
答案 0 :(得分:1)
很遗憾,您无法像这样创建自定义UIView,但它不起作用。我对可重用的自定义组件使用不同的方法: