这里的代码是从RootViewController启动的模态视图,用于在电影下方显示带缩略图幻灯片的视频,然后显示绑定到电影的定时指令.
这一切都有效,但有一个内存泄漏/缺乏发布,我看不出去寻找并花了三天时间试图解决它,现在是时候寻求帮助了......
如果我通过注释来禁用NSNotificationCenter(在.m中突出显示)我没有任何关于内存的问题并保留定时文本.但我也没有任何缩略图.我试过插入[[NSNotificationCenter alloc] removeObserver:self]; 在众多的地方,看看是否会为我摆脱它.但是,唉,无济于事.
我也试过发布'backgroundTimer'但是当我尝试编译和运行时它并没有给我留下太深刻的印象.
本质上,我第一次加载模态视图,没有任何问题,一切似乎都很好 - 但是,如果我用 - (IBAction)关闭它:(id)sender; 似乎有些事情没有发布,因为下次我启动相同的页面时内存使用量增加了大约30%(大致是缩略图生成使用的量),并且每次重新启动时增加的量大致相同模态视图.
请记住,我是一个新手,这个错误可能是一个血腥的愚蠢的你知道的人.但是为了完成这个项目,我很乐意接受你想要的任何虐待.
另外,这是我明天的生日,如果我可以对它进行排序,那将是(相当可悲)最好的礼物!
这是代码........
.H
#import <UIKit/UIKit.h>
#import <MediaPlayer/MPMoviePlayerController.h>
#import "ImageViewWithTime.h"
#import "CommentView.h"
@interface SirloinVideoViewController_iPad : UIViewController {
UIView *landscapeView;
UIView *viewForMovie;
MPMoviePlayerController *player;
UILabel *onScreenDisplayLabel;
UIScrollView *myScrollView;
NSMutableArray *keyframeTimes;
NSArray *shoutOutTexts;
NSArray *shoutOutTimes;
NSTimer *backgroundTimer;
UIView *instructions;
}
-(IBAction)close:(id)sender;
-(IBAction)textInstructions:(id)sender;
@property (nonatomic, retain) IBOutlet UIView *instructions;
@property (nonatomic, retain) NSTimer *theTimer;
@property (nonatomic, retain) NSTimer *backgroundTimer;
@property (nonatomic, retain) IBOutlet UIView *viewForMovie;
@property (nonatomic, retain) MPMoviePlayerController *player; …Run Code Online (Sandbox Code Playgroud)