cordova - Subview not closing causing Memory Leak Phonegap -
i having issues not being able close cdvviewcontroller when calling custom refresh, stays loaded in background , loads new 1 causing memory leaks/high memory usage. have tried use both release , removefromsuperview webview, subview, cdvviewcontroller, childviewcontroller none of them work. running tab bar controller via storyboard, (another reason why have call cdvviewcontroller subview) , when use web inspector via safari can see pages building on tab, , when refresh on tab (not using cdvviewcontroller/phonegap) works fine. appreciated.
so here .h
#import <uikit/uikit.h> #import <ifaddrs.h> #import <arpa/inet.h> #import <cordova/cdvviewcontroller.h> @interface thirdviewcontroller : cdvviewcontroller <uiwebviewdelegate> { iboutlet cdvviewcontroller *webview; iboutlet uiactivityindicatorview *activityind; } - (ibaction)refresh:(id)sender; @end
and .m
@interface thirdviewcontroller () @end @implementation thirdviewcontroller - (void)viewdidload { webview = [cdvviewcontroller new]; webview.startpage = @"mywebsite"; [self addchildviewcontroller:webview]; [self.webview addsubview:webview.view]; webview.view.frame = cgrectmake(0, 0, 0, 0); [activityind startanimating]; [self.webview addsubview: activityind]; [self customactivity]; } -(void) customactivity { if ([webview.reference isequaltostring:@"true"]){ //webview.reference added phonegap cdvviewcontroller able see when being loaded/used load custom activity/activity ind work. [activityind removefromsuperview]; }else{ [nstimer scheduledtimerwithtimeinterval:.5 target:self selector:@selector(customactivity) userinfo:nil repeats:no]; } } - (ibaction)refresh:(id)sender { webview = [cdvviewcontroller new]; webview.startpage = @"mywebsite"; [self addchildviewcontroller:webview]; [self.webview addsubview:webview.view]; webview.view.frame = cgrectmake (0,0,self.view.frame.size.width,(self.view.frame.size.height -44)); [activityind startanimating]; [self.webview addsubview: activityind]; [self customactivity]; } - (void)webviewdidstartload:(uiwebview *)webview {} - (void)webviewdidfinishload:(uiwebview *)subview {} - (void)loading {} - (void)didreceivememorywarning{[super didreceivememorywarning];} @end
found solution, had implement [webview.webview reload];
- (ibaction)refresh:(id)sender { [webview.webview reload]; }
Comments
Post a Comment