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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:23:33+00:00 2026-06-14T06:23:33+00:00

I have a UIView subclass, in some cases I need to change its color

  • 0

I have a UIView subclass, in some cases I need to change its color for some period, say 5 seconds, then change the color back, the method I used is performSelector:afterDelay: and the selector I passed in is to change the color back, I was wondering if the view is removed from superview, before the color changing method is fired, then does it cause any problem? Or it is just not called as the view object itself does not exist?

Thanks!

  • 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-06-14T06:23:35+00:00Added an answer on June 14, 2026 at 6:23 am

    When you send performSelector:withObject:afterDelay: to your view, the view essentially creates a timer. The timer retains the view, and the argument object (presumably a UIColor in your case). So even if you remove the view from its superview, the timer still retains the view and prevents it from being deallocated.

    When the timer fires, it will change the (off-screen) view’s background color, then release the view. If that was the last strong reference to the view, the view will then be deallocated.

    When you change the background color of a view that’s not in a window hierarchy, the view just remembers its new background color setting, but it doesn’t do anything else like try to draw itself on the screen.

    So using performSelector:withObject:afterDelay: to change your view’s background color should not cause any problems even if you remove the view from its superview before the delay expires.

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

Sidebar

Related Questions

If I have some instance of a class, say a UIView or subclass of
I have a UIScrollView which contains some small UIView subclass. UIScrollView is scroll enabled,
I have a UIView subclass that I am doing some custom drawing in. When
I have a subclass of UIView that's instantiated in a XIB file. I need
I have created a UIView subclass in order to implement a custom drawRect method.
I have a subclass s of UIView. I want to put some buttons and
I have a UITableView which uses a UIView subclass for its backgroundView and selectedBackgroundView
I have a custom NSManagedObject subclass, say, Person . I also have a UIView
I have a UIView subclass with an added observer for the UIKeyboardWillShowNotification and UIKeyboardWillHideNotification
I have a UIView subclass and I want the keyboard to appear when it

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.