uitouch locationInView not found

Discussion in 'iOS Development' started by danblack101, Feb 21, 2009.

  1. danblack101

    danblack101 New Member

    Joined:
    Feb 10, 2009
    Messages:
    11
    Likes Received:
    0
    Hi,
    I am having some trouble to the location of the touch event. The event is firing as expected but when I try to retrieve the CGPoint it errors.


    I am using @Class UITouch in my header file.

    Please ask if more details are required. Thanks
  2. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    have you tried in the locationInView instead of self try self.view

    I have never used touches in this way and so it may not be right. Just a note if you use view controllers you have to use self.view
  3. danblack101

    danblack101 New Member

    Joined:
    Feb 10, 2009
    Messages:
    11
    Likes Received:
    0
    Cheers mate. I'l give that a try.

    How do you handle touches if not this way?
  4. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    well no I meant I have never needed to use that as in the applications I have made I haven't needed to see if someone has touched the screen and at what point. I have only used touches as in buttons and other objects. Anyway please post back and tell us whether it works or not
  5. danblack101

    danblack101 New Member

    Joined:
    Feb 10, 2009
    Messages:
    11
    Likes Received:
    0
    Same stuff . "invalid initializer".

    Ive tried:
    CGPoint touchPoint = [touch locationInView:self];
    CGPoint touchPoint = [touch locationInView:self.view];
    CGPoint touchPoint = [touch locationInView];

    with no luck. What I think is odd though is
    works. So the touch object is getting instantiated ok. it just seems to be the locationInView method.
    Missing an import maybe? dunno
  6. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    Instead of:
    Code:
    CGPoint touchPoint = [touch locationInView:self];
    Put:
    Code:
    CGPoint touchPoint = [touch locationInView:touch.view];
  7. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    never thought of that stephen.4 it looks like it should work
  8. danblack101

    danblack101 New Member

    Joined:
    Feb 10, 2009
    Messages:
    11
    Likes Received:
    0
    Thanks Stephen but same problem. "invalid initializer".

    This is my header file
  9. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    What's wrong here?
    Code:
    CGPoint *touchDown;
  10. danblack101

    danblack101 New Member

    Joined:
    Feb 10, 2009
    Messages:
    11
    Likes Received:
    0
    That was a bit silly leaving that in there.
    I removed it, but still have the same error.

Share This Page