Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3636010
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:58:35+00:00 2026-05-19T00:58:35+00:00

Given the multitasking of iOS I thought it wouldn’t be a pain to pause

  • 0

Given the multitasking of iOS I thought it wouldn’t be a pain to pause and resume my app, by pressing the home button or due to a phone call, but for a particular view controller it crashes.

The navigation bar is working fine i.e. when I tap “Back” it’s ok, but if I try to tap controls of the displayed UI View Controller then I get EXC_BAD_ACCESS.. =/

Please find the code of my problematic View Controller below. I’m not very sure about it myself, because I used loadView to build its View. However apart from this interruption problem it works fine.

StoreViewController.h

#import <UIKit/UIKit.h>

@protocol StoreViewDelegate <NSObject>
@optional
- (void)DirectionsClicked:(double)lat:(double)lon;
@end

@interface StoreViewController : UIViewController 
{
    double latitude;
    double longitude;
    NSString *description;  
    NSString *imageURL;
    short rating;
    NSString *storeType;
    NSString *offerType;

    UIImageView *imageView;
    UILabel *descriptionLabel;

    id<StoreViewDelegate> storeViewDel;
}

@property (nonatomic) double latitude;
@property (nonatomic) double longitude;
@property (nonatomic) short rating;
@property (nonatomic,retain) NSString *description;
@property (nonatomic,retain) NSString *imageURL;
@property (nonatomic,retain) NSString *storeType;
@property (nonatomic,retain) NSString *offerType;
@property (assign) id<StoreViewDelegate> storeViewDel;

@end

StoreViewController.m

#import "StoreViewController.h"
#import <QuartzCore/QuartzCore.h>

@interface StoreViewController()

-(CGSize) calcLabelSize:(NSString *)string withFont:(UIFont *)font  maxSize:(CGSize)maxSize;

@end

@implementation StoreViewController

@synthesize storeViewDel, longitude, latitude, description, imageURL, rating, offerType, storeType;

- (void)mapsButtonClicked:(id)sender
{
}

- (void)loadView 
{
    UIView *storeView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 0.0f, 0.0f)];

    // Colours
    UIColor *lightBlue = [[UIColor alloc] initWithRed:(189.0f / 255.0f) 
                                              green:(230.0f / 255.0f) 
                                               blue:(252.0f / 255.0f) alpha:1.0f];

    UIColor *darkBlue = [[UIColor alloc] initWithRed:(28.0f/255.0f) 
                                                green:(157.0f/255.0f) 
                                                 blue:(215.0f/255.0f) 
                                                alpha:1.0f];

    // Layout
    int width = self.navigationController.view.frame.size.width;
    int height = self.navigationController.view.frame.size.height;
    float firstRowHeight = 100.0f;
    int margin = width / 20;
    int imgWidth = (width - 3 * margin) / 2;

    // Set ImageView 
    imageView = [[UIImageView alloc] initWithFrame:CGRectMake(margin, margin, imgWidth, imgWidth)];
    CALayer *imgLayer = [imageView layer];
    [imgLayer setMasksToBounds:YES];
    [imgLayer setCornerRadius:10.0f];
    [imgLayer setBorderWidth:4.0f];
    [imgLayer setBorderColor:[lightBlue CGColor]];
    // Load default image
    NSData *imageData = [NSData dataWithContentsOfFile:@"thumb-null.png"];
    UIImage *image = [UIImage imageWithData:imageData];
    [imageView setImage:image];

    [storeView addSubview:imageView];

    // Set Rating
    UIImageView *ratingView = [[UIImageView alloc] initWithFrame:CGRectMake(3 * width / 4 - 59.0f, 
                                                                        margin, 
                                                                        118.0f,
                                                                        36.0f)];
    UIImage *ratingImage = [UIImage imageNamed:@"bb-rating-0.png"];
    [ratingView setImage:ratingImage];
    [ratingImage release];

    [storeView addSubview:ratingView];

    // Set Get Directions button
    UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(3 * width / 4 - 71.5f, 
                                                               36.0f + 2*margin, 
                                                               143.0f, 63.0f)];
    [btn addTarget:self action:@selector(mapsButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    UIImage *mapsImgUp = [UIImage imageNamed:@"bb-maps-up.png"];
    [btn setImage:mapsImgUp forState:UIControlStateNormal];
    [mapsImgUp release];
    UIImage *mapsImgDown = [UIImage imageNamed:@"bb-maps-down.png"];
    [btn setImage:mapsImgDown forState:UIControlStateHighlighted];
    [mapsImgDown release];

    [storeView addSubview:btn];
    [btn release];

    // Set Description Text
    UIScrollView *descriptionView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0f, 
                                                                                   imgWidth + 2 * margin, 
                                                                                   width, 
                                                                                   height - firstRowHeight)];
    descriptionView.backgroundColor = lightBlue;
    CGSize s = [self calcLabelSize:description withFont:[UIFont systemFontOfSize:18.0f] maxSize:CGSizeMake(width, 9999.0f)];
    descriptionLabel = [[UILabel alloc] initWithFrame:CGRectMake(margin, margin, width - 2 * margin, s.height)];
    descriptionLabel.lineBreakMode = UILineBreakModeWordWrap;
    descriptionLabel.numberOfLines = 0;
    descriptionLabel.font = [UIFont systemFontOfSize:18.0f];
    descriptionLabel.textColor = darkBlue;
    descriptionLabel.text = description;
    descriptionLabel.backgroundColor = lightBlue;

    [descriptionView addSubview:descriptionLabel];
    [storeView addSubview:descriptionView];
    [descriptionLabel release];

    [lightBlue release];
    [darkBlue release];

    self.view = storeView;
    [storeView release];
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)dealloc 
{
[imageView release];
    [descriptionLabel release];

    [super dealloc];
}

@end

Any suggestions ?

Thank you,

F.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T00:58:35+00:00Added an answer on May 19, 2026 at 12:58 am

    The problem was that I released some UIImages that were never allocated. Erasing the following lines solved my issue:

    [ratingImage release];
    [mapsImgUp release];
    [mapsImgDown release];
    

    F.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the multitasking function of iOS, will other applications that are currently sleeping affect
I was experimenting with my app in the ios simulator when I found that
Given : InsuranceCompanies ( cid , name, phone, address) Doctors ( did , name,
Given this markup: // Calendar.html?date=1/2/2003 <script> $(function() { $('.inlinedatepicker').datepicker(); }); </script> ... <div class=inlinedatepicker
Given a package, how can I automatically find all its sub-packages?
Given these two queries: Select t1.id, t2.companyName from table1 t1 INNER JOIN table2 t2
Given a date range how to calculate the number of weekends partially or wholly
Given an interface or interfaces, what is the best way to generate an class
Given: unsigned int a, b, c, d; I want: d = a * b
Given Java's write once, run anywhere paradigm and the fact that the Java tutorials

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.