- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我遇到内存泄漏问题。在 Instruments 中,我在这条线上遇到内存泄漏:
VDLPlaybackViewController *videoController = [[VDLPlaybackViewController alloc] initWithNibName:@"VDLPlaybackView"bundle:nil];
我不确定这可能是什么问题。以下是 VDLPlaybackViewController.h
的头文件:
@protocol VDLPlaybackViewControllerDelegate <NSObject>
@required
-(void)playerShouldClose;
@end
@interface VDLPlaybackViewController : UIViewController <UIDocumentInteractionControllerDelegate>
@property (nonatomic, strong) id<VDLPlaybackViewControllerDelegate> delegate;
// content file stuff.
@property (nonatomic, strong) File *file;
@property (nonatomic, strong) NSNumber *contentID;
@property (nonatomic, strong) NSURL *fileURL;
@property (nonatomic, strong) NSString *pageTitle;
// layout stuff
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *topTimeViewHeight;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *bottomControlViewHeight;
@property (nonatomic, strong) IBOutlet UIView *movieView;
@property (nonatomic, strong) IBOutlet UIView *navBarView;
@property (nonatomic, strong) IBOutlet UISlider *positionSlider;
@property (nonatomic, strong) IBOutlet UIButton *timeDisplay;
@property (nonatomic, strong) IBOutlet UIButton *playPauseButton;
@property (nonatomic, strong) IBOutlet UIButton *subtitleSwitcherButton;
@property (nonatomic, strong) IBOutlet UIButton *audioSwitcherButton;
@property (nonatomic, strong) IBOutlet UIButton *screenSizeSwitcherButton;
//@property (nonatomic, strong) IBOutlet UINavigationBar *toolbar;
@property (nonatomic, strong) IBOutlet UIView *controllerPanel;
@property (nonatomic, strong) IBOutlet UISlider *volumeSlider;
@property (nonatomic, strong) IBOutlet MPVolumeView *volumeView;
@property (nonatomic, strong) IBOutlet MPVolumeView *airplayView;
@property (nonatomic, assign) CGRect shareButtonFrame;
@property (nonatomic, strong) MultiFileShareButtonController *shareButtonController;
@property (nonatomic, strong) FavoriteFileButtonView *favoriteButtonController;
@property (nonatomic, strong) UIDocumentInteractionController *interactionController;
@property (nonatomic, assign) BOOL isDestroying;
- (void)setMediaURL:(NSURL*)theURL;
- (IBAction)closePlayback:(id)sender;
- (IBAction)positionSliderDrag:(id)sender;
- (IBAction)positionSliderAction:(id)sender;
- (IBAction)toggleTimeDisplay:(id)sender;
- (IBAction)playandPause:(id)sender;
//- (IBAction)switchAudioTrack:(id)sender;
//- (IBAction)switchSubtitleTrack:(id)sender;
- (IBAction)switchVideoDimensions:(id)sender;
@end
有人知道是什么原因造成的吗?
最佳答案
检测工具告诉您以下行存在泄漏:
VDLPlaybackViewController *videoController = [[VDLPlaybackViewController alloc] initWithNibName:@"VDLPlaybackView"bundle:nil];
这并不意味着只是这一行导致了泄漏,该工具告诉您此变量的引用作为泄漏存在。
您应该寻找传递了对 VDLPlaybackViewController *videoController
的强引用的实例。可能作为委托(delegate)或在完成 block 中。
您在问题中使用的界面有一点问题。应该是弱而不是强
@property (nonatomic, weak) id<VDLPlaybackViewControllerDelegate> delegate;
找到更多这样的实例,在这些实例中,您将 VDLPlaybackViewController
作为强引用委托(delegate)传递,您将能够解决问题。
了解更多关于泄漏实际发生的原因。经过 https://cocoacasts.com/what-are-strong-reference-cycles
关于ios - `initWithNibName` 内存泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52951086/
我使用 initWithNibName 加载详细 View 。我只是在想这些东西有必要发布吗? init 基本上是添加了 1 的保留计数? 最佳答案 @梅尔: 是的,你需要释放它们。 Apple 文档
我的应用程序最近开始崩溃,我需要一些帮助来找出原因。 在应用程序委托(delegate)中,我创建了一个导航 Controller UINavigationController *localNavig
我刚刚开始使用 RubyMotion 学习 iOS 开发,我正在这样做 tutorial 。这似乎很容易理解,但现在我在运行 rake 命令时遇到了这个错误: ColorController.rb:7
我遇到内存泄漏问题。在 Instruments 中,我在这条线上遇到内存泄漏: VDLPlaybackViewController *videoController = [[VDLPlaybackVi
在尝试添加新 View 时遇到了这个非常令人沮丧的问题,我有 2 种不同类型的 View :LargeCoverViewController 和 CoverViewController。 我像这样创建
在我的基于导航的应用程序中,initWithNibName 方法没有被调用/触发 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBu
我肯定我错过了一些简单的东西。我试图在 iOS 中加载一个 subview (模态视图)作为单独的 Controller 。我创建了一个带有指向我的 Controller View 的窗口的 NIB
我想要一个自定义的 initWithNibName,基本上传入另一个 NSString 作为类型来确定此 UIViewController 中的一些逻辑基于类型。所以我设置如下: - (id)init
我需要将一些自定义逻辑放入我的 iPhone 应用程序中,以便根据您运行的 iOS 版本选择不同的 XIB 文件(即 iPhone 或 iPad 将显示不同的 XIB 文件)。 我从第一天开始就构建了
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super
这个问题已经有答案了: 已关闭11 年前。 Possible Duplicate: initWithNibName VS viewDidLoad 我是 iOS 开发新手。我只是想知道这两个功能之间的主
在 iPhone 应用程序中我需要将一些值传递给一个新的 View Controller 对象,同时它是从另一个 View Controller 类中的方法创建的,这样我就可以在新 View Cont
调用 initWithNib 后,我有额外的保留计数。什么可能导致这种情况? ( Nib 上没有引用点) StepViewController *stepViewController = [[Step
我正在按照 Facebook 的教程发布到用户的墙上:http://developers.facebook.com/docs/howtos/publish-to-feed-ios-sdk/虽然它是在考
我经常使用 initWithNibName 函数来初始化我的 View Controller 中的内容。我只是注意到生成的 initWithNibName 函数对 self 进行了 nil 检查。 -
我过去常常以编程方式创建我的 View ,并且已经开始使用 XIB 文件进行切换。我找到这段代码: -(id)init { self = [super initWithNibName:@"He
iOS 上的 initWithNibName 很聪明:它会自动为 iPad 而不是 iPhone 加载不同的 NIB(尽管很多人不知道这一点 - 它没有记录在 UIViewController.ini
我有一个 iOS 应用程序在模拟器上运行良好,但在所有设备上崩溃并出现此错误: : *** Assertion failure in -[UINib initWithNibName:directory
我想用 Xcode 4.2 的 Storyboard更改以下代码。 UIViewController * example = [[ExampleViewController alloc] in
谁能解释一下何时使用 initWithNibName 以及何时使用 initWithCoder? 最佳答案 initWithNibName: 通常与 View Controller 对象一起使用。这个
我是一名优秀的程序员,十分优秀!