getting memory allocation at ActivityIndicator in Iphone sdk
Here I'm gettimg memory allocation problem at activity indicator and my code is:
- (id)init {
if (self = [super init]) {
self.title=@"Release Details";
contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
contentView.backgroundColor = [UIColor clearColor];
self.view = contentView;
[contentView release];
CGRect frame = CGRectMake(0,0, 320,1500);
containerView = [[UIView alloc] initWithFrame:frame];
webView = [ [UIWebView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
webView.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"background1.png"]];
webView.delegate = self;
[containerView addSubview:webView];
CGRect activityViewframe = CGRectMake(20,8,20, 20);
progressInd = [[UIActivityIndicatorView alloc] initWithFrame:activityViewframe];
progressInd.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite;
progressInd.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin); [containerView addSubview:progressInd]; [progressInd startAnimating]; progressInd.hidden = NO; [progressInd stopAnimating]; [self.view addSubview:containerView]; isFetch=YES; } return self; }
-(void) displayInProgressRightBarButton
{
UIView* rightBarButtonView = [ [UIView alloc] initWithFrame:CGRectMake(270,5,45, 35)];
[rightBarButtonView addSubview:progressInd];
UIBarButtonItem* buttonItem = [[开发者_Python百科UIBarButtonItem alloc] initWithCustomView:rightBarButtonView];
self.navigationItem.rightBarButtonItem = buttonItem;
[rightBarButtonView release];
[buttonItem release];
}
- (void)webViewDidStartLoad:(UIWebView *)webView
{
[self displayInProgressRightBarButton];
[progressInd startAnimating];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[progressInd stopAnimating];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
Also I released the progressInd in dealloc eventhough it showing memory allocation at
progressInd = [[UIActivityIndicatorView alloc] initWithFrame:activityViewframe];
in init.
can anyone help me to solve this.
Anyone's help will be much Appreciated.
You can (and should) release it right after adding it to the container view:
[containerView addSubview:progressInd];
[progressInd release];
The same for the container view itself:
[self.view addSubview:containerView];
[containerView release];
The containing view will retain the subview for you, so you can release it right after adding it.
精彩评论