使用dismissModalViewControllerAnimated 不调用dealloc 内存不释放解决方法

在ARC项目中使用dismissModalViewControllerAnimated方法隐藏视图时,在dealloc里面打印NSlog检测该控制器有没有释放,结果没有打印出来,经过查找,是由于对这个控制器里面的协议指针赋值,但是这个协议的属性声明的是retain或者strong,要改成 assign。例如:

#import "MonthView.h"

@interface CalendarController ()<MonthViewDelegate>

@end

引入协议 MonthViewDelegate, 并在CalendarController 里面赋值 [ monthView setManage : self ];

@interface MonthView : UIView

@property (nonatomic,strong) id<MonthViewDelegate> manage;

@end


需要把strong改成assign ;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
#import "RespForWeChatViewController.h" #import "WXApiManager.h" #import "WXApiResponseHandler.h" #import "Constant.h" @implementation RespForWeChatViewController #pragma mark - View Lifecycle - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. [self setupHeadView]; [self setupLinesView]; [self setupFootView]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } else { return YES; } } - (void)dealloc { [super dealloc]; } #pragma mark - User Actions - (void)sendTextContent { [WXApiResponseHandler respText:kTextMessage]; [self dismissModalViewControllerAnimated:YES]; } - (void)sendImageContent { NSString *filePath = [[NSBundle mainBundle] pathForResource:@"res1" ofType:@"jpg"]; NSData *imageData = [NSData dataWithContentsOfFile:filePath]; UIImage *thumbImage = [UIImage imageNamed:@"res1thumb.png"]; [WXApiResponseHandler respImageData:imageData MessageExt:nil Action:nil ThumbImage:thumbImage]; [self dismissModalViewControllerAnimated:YES]; } - (void)sendLinkContent { UIImage *thumbImage = [UIImage imageNamed:@"res2.png"]; [WXApiResponseHandler respLinkURL:kLinkURL Title:kLinkTitle Description:kLinkDescription ThumbImage:thumbImage]; [self dismissModalViewControllerAnimated:YES]; } - (void)sendMusicContent { UIImage *thumbImage = [UIImage imageNamed:@"res3.jpg"]; [WXApiResponseHandler respMusicURL:kMusicURL dataURL:kMusicDataURL Title:kMusicTitle Description:kMusicDescription ThumbImage:thumbImage]; [self dismissModalViewControllerAnimated:YES]; } - (void)sendVideoContent { UIImage *thumbImage = [UIImage imageNamed:@"res4.jpg"]; [WXApiResponseHandler respVideoURL:kVideoURL Title:kVideoTitle Description:kVideoDescription ThumbImage:thumbImage]; [self dismissModalViewControllerAnimated:YES]; } - (void)sendAppContent { Byte* pBuffer = (Byte *)malloc(BUFFER_SIZE); memset(pBuffer, 0, BUFFER_SIZE); NSData* data = [NSData dataWithBytes:pBuffer length:BUFFER_SIZE]; free(pBuffer); UIImage *thumbImage = [UIImage imageNamed:@"res2.jpg"]; [WXApiResponseHandler respAppContentData:data ExtInfo:kAppContentExInfo ExtURL:kAppContnetExURL Title:kAPPContentTitle Description:kAPPContentDescription MessageExt:kAppMessageExt MessageAction:kAppMessageAction ThumbImage:thumbImage]; } - (void)sendNonGifContent { NSString *filePath = [[NSBundle mainBundle] pathForResource:@"res5" ofType:@"jpg"]; NSData *emoticonData = [NSData dataWithContentsOfFile:filePath]; UIImage *thumbImage = [UIImage imageNamed:@"res5thumb.png"]; [WXApiResponseHandler respEmotionData:emoticonData ThumbImage:thumbImage]; }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值