我知道这可能是一个重复的问题,但也有相互矛盾的答案!我对此感到困惑..我的问题是,当我使用仪器检查泄漏时我的应用程序进行分析..它一直显示此方法的泄漏loadNibNamed:
..所以与这些问题有关:
1。Do I need to release IBOutlets when using loadNibNamed: method?
2。Using loadNibNamed leaves a memory leak
我发现有些人说你必须释放IBOutlets
,即使你没有实现访问方法!其他人说你不应该释放这些网点,因为iOS会照顾它,所以请根据专业经验需要一个正确的答案,因为这需要我对我的项目做很多工作。
编辑/例如:
如果这是我的.h类文件
@interface MenuViewEPub : UIViewController<ePubBrightnessDelegate,FontDelegate,PagesSlidePreviewerDelegate,ePubExpandSearchBarDelegate,EnviromentAudioChooserDelegate,UIPopoverControllerDelegate,WEPopoverControllerDelegate> {
IBOutlet UIView *upperMenu;
IBOutlet UIView *lowerMenu;
IBOutlet ePubBrightnessButton *brightnessButton;
IBOutlet FontButton *fontButton;
IBOutlet UIBarButtonItem *backButtonTitle;
IBOutlet UIBarButtonItem *indexButtonTitle;
IBOutlet UIBarButtonItem *annotationButtonTitle;
UIView *readerView;
IBOutlet ePubExpandSearchBar *searchBar;
id<MenuViewControllerDelegat>delegate;
IBOutlet PagesSlidePreviewer *pageSilder;
IBOutlet UIButton *arEnButton;
int pageNumber;
int chapterIndex;
int chtCount;
BOOL isLandscape;
UIPopoverController *lastPopover;
}
@property (nonatomic, assign) id<MenuViewControllerDelegat>delegate;
@property (nonatomic, retain) ePubExpandSearchBar *searchBar;
@property (nonatomic, assign) int chtCount;
@property (nonatomic, assign) int pageNumber;
@property (nonatomic, assign) int chapterIndex;
@property (nonatomic, assign) BOOL isRotate;
- (IBAction)tocButtonPressed:(id)sender;
- (IBAction)AnnotationsPressed:(id)sender;
- (IBAction)BackPressed:(id)sender;
- (IBAction)rtfPressed:(id)sender;
- (IBAction) audioPressed:(UIButton*)sender;
- (IBAction) tipsPressed:(UIButton*)sender;
- (void) showMenuInView :(UIView*) destview;
- (void) createViews;
- (void) hideMenu : (BOOL)animate;
- (void) changePageNumber:(int)pageNum;
@end
我必须释放除 searchBar 之外的任何插座吗?
答案 0 :(得分:1)
除非您使用ARC,否则应在viewDidUnload
方法中释放所有保留的子视图。这将包括通过IBOutlets“注入”的子视图。您通常还会在viewDidLoad
方法中包含您自己创建的任何内容。