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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:45:42+00:00 2026-06-01T04:45:42+00:00

This is my code in which every line is giving me an invalid context

  • 0

This is my code in which every line is giving me an “invalid context” error when running the app in the iPad Simulator. Every statement after “self.Frame = frame; gives the error. How do I fix it?

- (void)makeFrame:(CGRect)frame number:(NSInteger) number color:(UIColor *) color {

    float rd1 = 225.00/255.00;
    float gr1 = 102.00/255.00;
    float bl1 = 0.00/255.00;

    float rd2 = 225.00/255.00;
    float gr2 = 153.00/255.00;
    float bl2 = 0.00/255.00;

    self.frame = frame;
    self.backgroundColor = [UIColor colorWithRed:rd1 green:gr1 blue:bl1 alpha:1.0]; 
    [[self layer] setBorderColor:[[UIColor blackColor] CGColor]]; 
    [[self layer] setBorderWidth:0.5];  
    [[self layer] setCornerRadius:10]; 
    self.tag = number;  //  set each button's tag
    [self setClipsToBounds: YES];

    //  do date label
    date = [[UILabel alloc]initWithFrame:CGRectMake(10, 2, 65, 40 )]; 
    date.backgroundColor = [UIColor clearColor]; //  x  y   w   h
    date.textColor = [UIColor colorWithRed:rd2 green:gr2 blue:bl2 alpha:1.0];
    date.text = [NSString stringWithFormat:@"%d", number];
    date.font = [UIFont boldSystemFontOfSize:40];
    //   date.alpha = 0.2;
    [self addSubview:date];
}

And this is the code which calls makeFrame:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    allButtons = [NSMutableArray array];
    for(int k = 40, m = 0; m < 6; m++, k+= 42)   //  this controls the vertical distance between rows
        for(int i = 0, j=32; i < 7; i++, j+=102) {  //  this controls the size and horizontal distance
            calendarButton *cb= [calendarButton buttonWithType:UIButtonTypeCustom];
            [cb makeFrame:CGRectMake(j, k, 100, 40) number: allButtons.count+1 color:[UIColor orangeColor]];
            //                       x  y   w   h
            [self.view addSubview:cb];
            [allButtons addObject:cb];  // put it in the array
        }

    calendarButton *cb= [calendarButton buttonWithType:UIButtonTypeCustom];
    [cb drawRect:CGRectMake(0,0, 100, 40)];   //  150
  • 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-01T04:45:44+00:00Added an answer on June 1, 2026 at 4:45 am

    You’re manually calling drawRect, which I suspect is causing this problem. From the docs:

    You should never call this method directly yourself. To invalidate part of your view, and thus cause that portion to be redrawn, call the setNeedsDisplay or setNeedsDisplayInRect: method instead.

    This doesn’t look necessary in this case, though. The view has been added as a subview of your view; it will automatically draw itself when your view renders.

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

Sidebar

Related Questions

So I have this code which is called in a print_info() function after a
OK, so this code below sometimes crashes on the line below //bug!! The error
I use this code which is taken from MVC futures and attach the Attribute
I have this code which is called at an onChange event of an function
I have this code which gets WP posts, but it gets all the posts
I have this code (which is way simplified from the real code): public interface
I have this code which compiles and works as expected: class Right {}; class
I have this code which will include template.php file from inside each of these
I have this code which should create a splash image with either no animation
I have this code which is passed to Paypal checkout: <?php foreach ($paypalBasket as

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.