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

  • Home
  • SEARCH
  • 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 6815103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:46:01+00:00 2026-05-26T20:46:01+00:00

Sir, – (void)viewDidLoad{ for (int i = 1; i <= 4; i++) { playButton=[[UIButton

  • 0

Sir,

- (void)viewDidLoad{
for (int i = 1; i <= 4; i++)
{
   playButton=[[UIButton alloc]initWithFrame:CGRectMake(curLocX,1.0,45,kScrollObjHeight)];
    [playButton   setBackgroundImage:[UIImage imageNamed:@"Play.png"] forState:UIControlStateNormal];
    [playButton addTarget:self  action:@selector(playClicked) forControlEvents:UIControlEventTouchUpInside];
  curLocX+=100;
   }}

I have release the playButton in viewDidUnload and dealloc
1.I have created four buttons but I released only one time its right or wrong
2.I have released viewDidUnload and dealloc its right or wrong
Advance Thanks for your valuable suggestions
Suresh.M

  • 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-26T20:46:02+00:00Added an answer on May 26, 2026 at 8:46 pm

    yes, if an object has been allocated 4 times, it should be released by the same number of count.

    btw am not sure what are you trying to do here, at the end of the loop playButton will only have reference to the last object and you are not even adding your playButton as a subview to any view. Anyways you can avoid using the alloc and user buttonWithType method, this method itself handles the alloc and release of UIButton object so you don’t have to worry about the release call.

    - (void)viewDidLoad{
    for (int i = 1; i <= 4; i++)
    {
        UIButton *playButton = [UIButton buttonWithType: UIButtonTypeCustom];
        playButton.frame = CGRectMake(curLocX,1.0,45,kScrollObjHeight);
        [playButton   setBackgroundImage:[UIImage imageNamed:@"Play.png"] forState:UIControlStateNormal];
        [playButton addTarget:self  action:@selector(playClicked) forControlEvents:UIControlEventTouchUpInside];
        curLocX+=100;
        [self.view addSubview: playButton]; //you might have missed this statement
    

    }}

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

Sidebar

Related Questions

I am trying to implement the SIR epidemic model . Basically, the way I
Given a document written with normal quotes, e.g. Ben said buttons, dear sir. I
Sir/Madam, I want to know where WSDL exists. Do user need to do interact
$(.menu-container).animate({top:25px}); $(.menu-container).animate({top:-900px}); $(.windows-container).animate({top:-730px}); hello sir.. i got a problem on queue in jquery.. what
sir when i insert a long string data the table size comes out of
Edited........ sorry Sir I was referring this piece of code from Stephen Toub's article..
sir i have got an error while running my project in ecclipse. The error
Sir, I am developing an application in which i am to save some information
Dear Sir/m'am How can i replace ther deprecated ereg_replace with preg_replace or str_replace and
This is correct program and now running fine :) thank you sir I am

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.