我得到了这些代码的30,用相同的实现:IBOutlet中的UIImageView
// .H
@interface ViewController : UIViewController{
IBOutlet UIImageView *circle;
IBOutlet UIImageView *circle2;
}
@property (nonatomic, retain) IBOutlet UIImageView *circle;
@property (nonatomic, retain) IBOutlet UIImageView *circle2;
// .M
@implementation ViewController
@synthesize circle;
@synthesize circle2;
- (void)viewDidLoad
{
circle = [[UIImageView alloc]
initWithImage:[UIImage imageNamed:@"Circle.png"]];
circle2 = [[UIImageView alloc]
initWithImage:[UIImage imageNamed:@"Circle.png"]];
}
而且在我的代码的某个地方,进出口将其添加为子视图。
我的问题是,有没有办法缩短它的维护时间。
你是什么意思缩短和为什么你使用IBOutlet时编程创建UIImageView? – saadnib
我应该使用什么? – Bazinga
仅当需要与XIB文件建立连接时才需要IBOutlet,但由于您不在XIB中创建这些图像视图,因此无需在此处添加IBOutlet。 – saadnib