我得到了這些代碼的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