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 645095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:27:52+00:00 2026-05-13T21:27:52+00:00

I have an app that uses a tableview, along with a UIButton that I

  • 0

I have an app that uses a tableview, along with a UIButton that I add as a subview to each custom cell, like this:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];

    checkButton = [[UIButton buttonWithType:UIButtonTypeCustom] initWithFrame:CGRectMake(2.0, 2.0, 40.0, 40.0)];
    [cell.contentView addSubview:checkButton];

    // lot's of other code

    return cell;
}

I thought all was fine until I started using Instruments to make sure I didn’t have any memory leaks, but I’ve found that adding the UIButton as a subview of the cell like that somehow causes a leak within UIKit.

Specifically, I get a memory leak for each cell row (for each time the button is added as a subview), and the leaked object is “CALayer” with the responsible frame being “-[UIView _createLayerWithFrame:]”.

Am I doing something wrong here?

  • 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-13T21:27:53+00:00Added an answer on May 13, 2026 at 9:27 pm

    The code [UIButton buttonWithType] method already includes an initWithFrame method. You need to just use a CGRectMake, and then set the frame of the button.

    rectangle = CGRectMake(2.0f,2.0f,40.0f,40.0f);
    checkButton = [UIButton buttonWithType:UIButtonTypeCustom];
    checkButton.frame = rectangle;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app that uses a custom UITableViewCell to display detail information after
I have an app that uses the navigation controls. What I would like is
I have a app that uses a classic email like layout like the one
I have a mac app that uses tableView that has some rows.On taping(single tap
I have an iphone app that uses table view as the interface. Each time
I have an app that uses the ActionBar with tabs in combination with Fragments.
I have an app that uses webView. In the home screen of a website
I have an app that uses a transition file to flip from page to
I have an app that uses the built-in flip animation to switch between the
I have an app that uses EF. To test my stuff I generally wrap

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.