получение выделения памяти в ActivityIndicator в Iphone SDK - PullRequest
0 голосов
/ 25 марта 2010

Здесь у меня проблема с выделением памяти у индикатора активности, и мой код:

- (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 |

UIViewAutoresizingF flexRightMargin | UIViewAutoresizingF flexTopMargin | UIViewAutoresizingFlexibleBottomMargin); [containerView addSubview: progressInd]; [progressInd startAnimating]; progressInd.hidden = NO; [progressInd stopAnimating]; [self.view addSubview: containerView]; isFetch = ДА; } вернуть себя; }

-(void) displayInProgressRightBarButton
{
    UIView* rightBarButtonView = [ [UIView alloc] initWithFrame:CGRectMake(270,5,45, 35)];
    [rightBarButtonView addSubview:progressInd];
    UIBarButtonItem* buttonItem = [[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;
}

Также я выпустил progressInd в dealloc, хотя он показывает распределение памяти на

progressInd = [[UIActivityIndicatorView alloc] initWithFrame:activityViewframe];

в иници.

Может кто-нибудь помочь мне решить эту проблему.

Любая помощь будет высоко ценится.

1 Ответ

0 голосов
/ 25 марта 2010

Вы можете (и должны) выпустить его сразу после добавления в представление контейнера:

[containerView addSubview:progressInd];
[progressInd release];

То же самое для самого контейнера:

[self.view addSubview:containerView];
[containerView release];

Содержащий вид сохранит для вас подпредставление, поэтому вы можете освободить его сразу после добавления.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...