• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Frame Origin Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Frame Origin Problem


  • Subject: Re: Frame Origin Problem
  • From: Chunk 1978 <email@hidden>
  • Date: Thu, 11 Jun 2009 17:27:31 -0400

should this code work?  if there don't appear to be any errors i'm
concerned it may be a bug, but i can't be sure.  :-/

On Thu, Jun 11, 2009 at 7:15 AM, Chunk 1978<email@hidden> wrote:
> while dragging (touching) a view, i'm trying to anchor the view in the
> center of the screen and resize the view's width and height based on
> the drag, but it's flashes all crazy and i can't figure out why it's
> doing so.  i think it has to do with the resetting of the origin
> because if i set the origin of the view to a static location in the
> (void)touchesMoved method, it works fine, but since the drag resizes
> the view, it also (is suppose to) changes it's origin.  i've been in
> front of this for 4 hours with no luck.  please help.
>
> -=-=-=-=-=--=-
> - (void)viewDidLoad
>        {
>        CGRect fullScreenRect = [[UIScreen mainScreen] bounds];
>
>        UIView *aView = [[UIView alloc] initWithFrame:fullScreenRect];
>        aView.backgroundColor = [UIColor redColor];
>        self.background = aView;
>        [aView release];
>
>        CGRect aFrame = CGRectMake(0, 0, 50, 50);
>        aFrame.origin = CGPointMake(CGRectGetMidX(fullScreenRect) -
> CGRectGetMidX(aFrame), CGRectGetMidY(fullScreenRect) -
> CGRectGetMidY(aFrame));
>
>        UIView *aBoxView = [[UIView alloc] initWithFrame:aFrame];
>        aBoxView.backgroundColor = [UIColor whiteColor];
>        self.boxView = aBoxView;
>        [aBoxView release];
>
>        [self.view insertSubview:background atIndex:0];
>        [self.view insertSubview:boxView atIndex:1];
>
>        [super viewDidLoad];
>        }
>
>
> - (void)dealloc
>        {
>        [background release];
>        [boxView release];
>        [super dealloc];
>        }
>
>
> #pragma mark Touch Methods
>
> - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
>        {
>        CGPoint point = [[touches anyObject] locationInView:self.view];
>        firstTouchPoint = point;
>        }
>
> - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
>        {
>        CGRect fullScreenRect = [[UIScreen mainScreen] bounds];
>
>        CGPoint point = [[touches anyObject] locationInView:self.view];
>        CGRect boxFrame = boxView.frame;
>
>        boxFrame.size.width += point.x - firstTouchPoint.x;
>        boxFrame.size.height += point.y - firstTouchPoint.y;
>        boxFrame.origin = CGPointMake(CGRectGetMidX(fullScreenRect) -
> CGRectGetMidX(boxFrame), CGRectGetMidY(fullScreenRect) -
> CGRectGetMidY(boxFrame));
>
>        [boxView setFrame:boxFrame];
>        firstTouchPoint = point;
>
>        NSString *log = [NSString stringWithFormat:@"%f, %f",
> boxFrame.origin.x, boxFrame.origin.y];
>        NSLog(log);
>        }
>
> -=-=-=-=-=-=-=-
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Frame Origin Problem (From: Chunk 1978 <email@hidden>)

  • Prev by Date: Re: Passing References During Initialization / Nib Loading
  • Next by Date: Re: App does not start on a different machine
  • Previous by thread: Frame Origin Problem
  • Next by thread: Foundation tool & NSUserDefault
  • Index(es):
    • Date
    • Thread