簡體   English   中英

IBOutlets和內存管理

[英]IBOutlets and memory management

我知道這可能是一個重復的問題,但是關於它的答案也有矛盾! 我對此不太困惑。我的問題是,當我使用儀器來分析我的應用程序以檢查泄漏時..該方法在此方法下loadNibNamed:顯示泄漏loadNibNamed: ..所以與這些問題相關:

1. 使用loadNibNamed:方法時是否需要釋放IBOutlets?

2. 使用loadNibNamed會導致內存泄漏

我發現有些人說,即使不實現訪問器方法,也必須釋放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,我是否必須釋放任何插座?

除非使用ARC,否則應在viewDidUnload方法中釋放所有保留的子視圖。 這將包括通過IBOutlet“注入”的子視圖。 通常,您還將在viewDidLoad方法中包括自己可能創建的任何內容。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM