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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:26:47+00:00 2026-05-26T22:26:47+00:00

I am having a problem with my background and frame whenever I turn my

  • 0

I am having a problem with my background and frame whenever I turn my iPad to landscape.

Portrait:

enter image description here

Landscape: I can’t paint on that side after the yellow arrow and my background is still in portrait and repeating itself.

enter image description here

Here’s my code

on viewDidLoad:

    background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"mickey.png"]];
    self.view.backgroundColor = background;

    touchDraw = [[UIImageView alloc] initWithImage:nil];
    touchDraw.frame = self.view.frame;
    [self.view addSubview:touchDraw];
    [self.view sendSubviewToBack:touchDraw];
    touchMoved = 0;

on touchesMoved:

    touchSwiped = YES;
    UITouch *touch = [touches anyObject];   
    currentTouch = [touch locationInView:self.view];
    currentTouch.y -= 20;
    UIGraphicsBeginImageContext(self.view.frame.size);
    [touchDraw.image drawInRect:CGRectMake(0, 0, touchDraw.bounds.size.width, touchDraw.bounds.size.height)];
    CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
    CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 25.0);
    CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), redAmt, greenAmt, blueAmt, alpha);
    CGContextBeginPath(UIGraphicsGetCurrentContext());
    CGContextMoveToPoint(UIGraphicsGetCurrentContext(), endingPoint.x, endingPoint.y);
    CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentTouch.x, currentTouch.y);
    CGContextStrokePath(UIGraphicsGetCurrentContext());
    touchDraw.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    endingPoint = currentTouch;

    touchMoved++;

    if (touchMoved == 10) {
        touchMoved = 0;
    }

It’s for my school project.

UPDATE:

When I applied the autoResizingMask this happens on touchesMoved.

enter image description here

maybe because of this line:

[touchDraw.image drawInRect:CGRectMake(0, 0, touchDraw.bounds.size.width, touchDraw.bounds.size.height)];

I tried to fix that before but still the same.

  • 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-26T22:26:48+00:00Added an answer on May 26, 2026 at 10:26 pm

    From quickly reading over your code, here is my guess as to what is wrong.

    Your main view is responding to the orientation change which is why it is redrawing when you rotate your device. You painted a pattern, and patterns repeat. If you want to have a background that doesn’t repeat, you would need to create a UIImageView and set its image to “mickey.png”

    The view that you create (touchDraw) is being given a frame when it is created, and it is not dynamically updating when the iPad is rotated.

    I think that all you should need to do is:

    touchDraw.autoresizingMask = UIViewAutoresizingFlexibleHeight
        | UIViewAutoresizingFlexibleWidth;
    

    This tells the view that it should auto-adjust when orientations change.

    You might also need to add this method to your view controller (I forget what the default is for this):

    - (BOOL)shouldAutorotateToInterfaceOrientation:
        (UIInterfaceOrientation)interfaceOrientation {
        return YES;
    }
    

    You can have more fine-grained control over orientation changes by adding these two methods to your view controller:

    - (void)willRotateToInterfaceOrientation: (UIInterfaceOrientation) orient
                                    duration: (NSTimeInterval) duration
    

    and

    - (void) didRotateFromInterfaceOrientation:
        (UIInterfaceOrientation) orientation {
    

    Note that it is hard to see where your views are without a border. For debugging, you can set a border using:

        touchDraw.layer.borderWidth = 1;
        touchDraw.layer.borderColor = [[UIColor blackColor] CGColor];
    

    I think to access the layer property above, you will also need to include this #import:

    #import <QuartzCore/QuartzCore.h>
    

    When I’m playing around with the locations for my views, I often add the borders so I can clearly see where my views are.

    Note that there is probably a setting in “Interface Builder” to set the auto-rotation, but you are creating your view in C-code, so it is not being set.

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

Sidebar

Related Questions

I am having problem here with bitmaps..I want to remove the black background that
I am having a problem setting the background of UITableView to a UIImageView (see
We are having problem with the server migration. We have one application that are
Hi I'm having problem refreshing my listview after Async operation. I have a simplecursoradapter,
I am having a problem that is strange to me but hopefully is not
Hi I'm having a problem with my project. I have a background job running
I am having a problem with a background image not showing. I have a
im having a problem regarding using background property with url('location') value with a div
I am having a problem with a UIView that when using a solid colour
I'm having a problem with the following html/css: http://jsfiddle.net/QYVPb/ <table cellpadding=0 cellspacing=0 style=background:#FAFAFA; border:1px

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.