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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:02:10+00:00 2026-05-23T08:02:10+00:00

I can’t see what the problem is with my code. Nothing happens when I

  • 0

I can’t see what the problem is with my code. Nothing happens when I press the button, like as if the default state wasn’t even set, which is weird because we can’t do something playButton.state = UIControlStateNormal since the state property is read-only.

This is my code:

- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {

    // ...

    playButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    playButton.frame = CGRectMake(100, 500, 100, 50);
    [playButton setTitle:@"play" forState: UIControlStateNormal];
    [playButton setTitle:@"stop" forState: UIControlStateSelected];
    playButton.exclusiveTouch = YES;
    playButton.selected = NO;
    [playButton addTarget:self action:@selector(play) forControlEvents:UIControlEventTouchUpInside];

and

- (void) play {

    if (playButton.state == UIControlStateNormal) {

        playButton.selected = YES;

        CABasicAnimation *maskAnim = [CABasicAnimation animationWithKeyPath:@"position.x"];
        maskAnim.byValue = [NSNumber numberWithFloat:diagramWidth];
        maskAnim.repeatCount = HUGE_VALF;
        maskAnim.duration = 1.750f;
        [self.maskLayer addAnimation:maskAnim forKey:@"position.x"];
        self.diagramLayer.mask = maskLayer;

        [backImageLayer addSublayer: self.diagramLayer];


        [audioPlayerNormal play];
        [moviePlayerNormal play]; 


    }
        else if (playButton.state == UIControlStateSelected) {

            playButton.selected = NO;

            [self.maskLayer removeAnimationForKey:@"position.x"];
            self.diagramLayer.mask = nil;

            [audioPlayerNormal stop];
            [moviePlayerNormal stop];

        }

}
  • 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-23T08:02:11+00:00Added an answer on May 23, 2026 at 8:02 am

    The following code should do the job.

    - (void) play {
    
        if (playButton.selected == NO) {
    
            CABasicAnimation *maskAnim = [CABasicAnimation animationWithKeyPath:@"position.x"];
            maskAnim.byValue = [NSNumber numberWithFloat:diagramWidth];
            maskAnim.repeatCount = HUGE_VALF;
            maskAnim.duration = 1.750f;
            [self.maskLayer addAnimation:maskAnim forKey:@"position.x"];
            self.diagramLayer.mask = maskLayer;
    
            [backImageLayer addSublayer: self.diagramLayer];
    
    
            [audioPlayerNormal play];
            [moviePlayerNormal play]; 
    
    
        }
        else {
            [self.maskLayer removeAnimationForKey:@"position.x"];
            self.diagramLayer.mask = nil;
    
            [audioPlayerNormal stop];
            [moviePlayerNormal stop];
    
        }
        playButton.selected = !playButton.selected;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can we set the alpha of drawable for its disable state through XML? For
Can anyone tell me how I can display a status message like 12 seconds
Can i get the source code for a WAMP stack installer somewhere? Any help
Can you have submenus with the top level set to checkable in WPF? I
Can we close all known/unknown connections to database with the code? I'm using Access
Can't seem to get the Back Button to appear in a UINavigationController flow. I
Can someone tell me the regex to see if something is surrounded in double
can you show me how to assign css properties to the button that is
Can someone help me? I am trying to do something like the following: #include
Can anyone can confirm the best idea for storing jquery code, initially i was

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.