Search Results

Search found 196 results on 8 pages for 'nsset'.

Page 4/8 | < Previous Page | 1 2 3 4 5 6 7 8  | Next Page >

  • iPhone smooth move and pinch of UIImageView

    - by Jacob
    I have an image view that I'm wanting to be able to move around, and pinch to stretch it. It's all working, but it's kinda jumpy when I start to do any pinch movements. The position will jump back and forth between the two fingers. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { startLocation = [[touches anyObject] locationInView:mouth_handle]; if([touches count] == 2) { NSArray *twoTouches = [touches allObjects]; UITouch *first = [twoTouches objectAtIndex:0]; UITouch *second = [twoTouches objectAtIndex:1]; initialDistance = distanceBetweenPoints([first locationInView:mouth_handle],[second locationInView:mouth_handle]); } } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { CGPoint pt = [[touches anyObject] locationInView:mouth_handle]; CGRect frame = [mouth_handle frame]; frame.origin.x += pt.x - startLocation.x; frame.origin.y += pt.y - startLocation.y; frame.origin.x = (frame.origin.x < 58) ? 58 : frame.origin.x; frame.origin.x = (frame.origin.x > (260 - mouth_handle.frame.size.width)) ? (260 - mouth_handle.frame.size.width) : frame.origin.x; frame.origin.y = (frame.origin.y < 300) ? 300 : frame.origin.y; frame.origin.y = (frame.origin.y > 377) ? 377 : frame.origin.y; if(frame.origin.x - prevDistanceX > 2 && frame.origin.x - prevDistanceX < -2) frame.origin.x = prevDistanceX; if(frame.origin.y - prevDistanceY > 2 && frame.origin.y - prevDistanceY < -2) frame.origin.y = prevDistanceY; prevDistanceX = frame.origin.x; prevDistanceY = frame.origin.y; CGFloat handleWidth = mouth_handle.frame.size.width; if([touches count] == 2) { NSArray *twoTouches = [touches allObjects]; UITouch *first = [twoTouches objectAtIndex:0]; UITouch *second = [twoTouches objectAtIndex:1]; CGFloat currentDistance = distanceBetweenPoints([first locationInView:mouth_handle],[second locationInView:mouth_handle]); handleWidth = mouth_handle.frame.size.width + (currentDistance - initialDistance); handleWidth = (handleWidth < 60) ? 60 : handleWidth; handleWidth = (handleWidth > 150) ? 150 : handleWidth; if(initialDistance == 0) { initialDistance = currentDistance; } initialDistance = currentDistance; } mouth_handle.frame = CGRectMake(frame.origin.x, frame.origin.y, handleWidth, 15); } Any thoughts on how to make this smoother?

    Read the article

  • Detecting double tap in UIScrollView

    - by william-hu
    Hi, i searched much, the main way is subclass, override -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { } but i use NSL(@"") in this method to display the times ,but can't work ,who can give me a way to detect double click in detail.thank you so much!

    Read the article

  • Alternative of touchesMoved in Unity3D

    - by Arman
    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; CGPoint location = [touch locationInView:touch.view]; CGPoint xLocation = CGPointMake(location.x,racquet_yellow.center.y); racquet_yellow.center = xLocation; } The above event move recquet_yellow(UIImageView) with mouse pointer, or when I move thumb on iPhone screen, I have 3D Object in Unity3D how can I move my object like recquet_yellow. Kindly guide me.

    Read the article

  • How to handle an array of pointers in Objective-C

    - by DougW
    I figured out the answer to this question, but I couldn't find the solution on here, so posting it for posterity. So, in Objective-C, how do you create an object out of a pointer in order to store it in objective-c collections (NSArray, NSDictionary, NSSet, etc) without reverting to regular C?

    Read the article

  • touchesEnded Sound?

    - by NextRev
    I'm trying to play a sound on touchesEnded but I'm having a problem. There are multiple objects that get moved around, so if the below code holds true when any object is moved, it constantly plays the sound. How do I only play it once? -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ if(CGRectContainsRect([image1 frame], [image2 frame])){ [self playsound]; } }

    Read the article

  • which touch event to use to slide an image??

    - by hemant
    i am using the following function to move a ball from one location to another wherever user touches the screen..right now i dont have an i-phone to test my application and i am new to i-phone application programming so i wanted to know does this event will also make the ball slide from one point to another wen user maintains the touch?? -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch=[[event allTouches] anyObject]; CGPoint location=[touch locationInView:touch.view]; fball.center=location; }

    Read the article

  • View doesn't respond to touches after shake

    - by Mike Rychev
    In my app I've implemented a shake event and it shows a UIImageView. When the UIImageView is shown, I hide the Nav Bar with: [self.navigationController setNavigationBarHidden:YES animated:NO]; And after that I want to bring it back when user touches the screen: - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { [[self navigationController] setNavigationBarHidden:NO animated:YES]; } But it doesn't work! Like my view doesn't respond to touches. Thanks in advance!

    Read the article

  • Not sure how to use ccTouchesBegan to do what I want it to do.

    - by thyrgle
    So when I see ccTouchesBegan (or touchesBegan for that fact of the matter) I see something like this usually: - (void)ccTouchesBegan:(NSSet*)touches withEvent:(UIEvent*)event { UITouch* touch = [touches anyObject]; } But, what I am not getting is how do you just detect if one object has been touched? For example how would I check if a specific CCSprite I declared has been touched? Sorry if this is a newbish question but, I just don't understand and if you need more clarification just ask how I can clarify myself more.

    Read the article

  • UITextView disabling text selection

    - by dizy
    I'm having a hard time getting the UITextView to disable the selecting of the text. I've tried: canCancelContentTouches = YES; I've tried subclassing and overwriting: - (BOOL)canPerformAction:(SEL)action withSender:(id)sender (But that gets called only After the selection) - (BOOL)touchesShouldCancelInContentView:(UIView *)view; (I don't see that getting fired at all) - (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view; (I don't see that getting fired either) What am I missing ?

    Read the article

  • drag object vertically

    - by blacksheep
    i like to drag this object vertically instead of horizontally, which is doin it now: (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; CGPoint location = [touch locationInView:touch.view]; if (CGRectContainsPoint(myObject.frame, location)){ CGPoint xLocation = CGPointMake(location.x, myObject.center.y); myObject.center = xLocation; } }

    Read the article

  • How to resize the UIView when CGAffineTransformIdentity

    - by Gowtham
    I am doing an app which has a feature to rotate and re size a view. i have implemented this feature but i do face an issue. My problem The View wil be resized when dragging its four corners, after resizing it i can rotate the view in both directions. Once the rotation is done, if i try again to resize the view by dragging its corner, the view's size gone to unpredictable value and its moving all around the screen. I googled lot finally i got the following solution The frame property is undefined when transform != CGAffineTransformIdentity, as per the docs on UIView I saw one app which has implemented the feature exactly what i wish to implement. How can i resize the UIView after rotation of UIView My code for resize the view Touches Began - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [[event allTouches] anyObject]; NSLog(@"[touch view]:::%@",[touch view]); touchStart = [[touches anyObject] locationInView:testVw]; isResizingLR = (testVw.bounds.size.width - touchStart.x < kResizeThumbSize && testVw.bounds.size.height - touchStart.y < kResizeThumbSize); isResizingUL = (touchStart.x <kResizeThumbSize && touchStart.y <kResizeThumbSize); isResizingUR = (testVw.bounds.size.width-touchStart.x < kResizeThumbSize && touchStart.y<kResizeThumbSize); isResizingLL = (touchStart.x <kResizeThumbSize && testVw.bounds.size.height -touchStart.y <kResizeThumbSize); } Touches Moved - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ CGPoint touchPoint = [[touches anyObject] locationInView:testVw]; CGPoint previous=[[touches anyObject]previousLocationInView:testVw]; float deltaWidth = touchPoint.x-previous.x; float deltaHeight = touchPoint.y-previous.y; NSLog(@"CVTM:%@",NSStringFromCGRect(testVw.frame)); if (isResizingLR) { testVw.frame = CGRectMake(testVw.frame.origin.x, testVw.frame.origin.y,touchPoint.x + deltaWidth, touchPoint.y + deltaWidth); } if (isResizingUL) { testVw.frame = CGRectMake(testVw.frame.origin.x + deltaWidth, testVw.frame.origin.y + deltaHeight, testVw.frame.size.width - deltaWidth, testVw.frame.size.height - deltaHeight); } if (isResizingUR) { testVw.frame = CGRectMake(testVw.frame.origin.x ,testVw.frame.origin.y + deltaHeight, testVw.frame.size.width + deltaWidth, testVw.frame.size.height - deltaHeight); } if (isResizingLL) { testVw.frame = CGRectMake(testVw.frame.origin.x + deltaWidth ,testVw.frame.origin.y , testVw.frame.size.width - deltaWidth, testVw.frame.size.height + deltaHeight); } if (!isResizingUL && !isResizingLR && !isResizingUR && !isResizingLL) { testVw.center = CGPointMake(testVw.center.x + touchPoint.x - touchStart.x,testVw.center.y + touchPoint.y - touchStart.y); } }

    Read the article

  • How to create Button dynamically in -(void)touchesBegan() function call in iPad

    - by chaitanya
    HI, I am trying to create buttons and text views on touch events from WebView. I am creating the Button creation code in below code. -(void)touchesBegan: ( NSSet* )touches withEvent : (UIEvent ) event{ } capturng of the touch events is happening properly and above fucntion is called also. But the button creation is not happening. PLease suggest that what could be the issue with approach.

    Read the article

  • Xcode: How to change Image on Touching at an Image (same Position)?

    - by Markus S.
    Simply, I have placed an image with the Interface Builder in a UIView. Now I want to run a method/function when I am touching that image, for example when another image should be loaded. My Code: - (void)touchesended:(NSSet*) touches withEvent:(UIEvent *)event { // UITouch *touch = [touch anyObject]; bild_1_1.image = [UIImage imageNamed:@"t_1_4.jpg"]; //} }

    Read the article

  • Wheel rotation, to change velocity of vehicle

    - by Lewis
    I update the velocity of my vehicle like so: [v setVelocity: ((2 * 3.14 * 100 * (wheel.getRotationValue / 360) / 30)) * gameSpeed]; // update on 60 fps this gets velocity on all frames divide by 60 for 1 frame. This is done in my update method in my world class. Now wheel.getRotationValue returns the rotation value which is worked out like this: - (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint location = [touch locationInView:[touch view]]; location = [[CCDirector sharedDirector] convertToGL:location]; if (CGRectContainsPoint(wheel.boundingBox, location)) { CGPoint firstLocation = [touch previousLocationInView:[touch view]]; CGPoint location = [touch locationInView:[touch view]]; CGPoint touchingPoint = [[CCDirector sharedDirector] convertToGL:location]; CGPoint firstTouchingPoint = [[CCDirector sharedDirector] convertToGL:firstLocation]; CGPoint firstVector = ccpSub(firstTouchingPoint, wheel.position); CGFloat firstRotateAngle = -ccpToAngle(firstVector); CGFloat previousTouch = CC_RADIANS_TO_DEGREES(firstRotateAngle); CGPoint vector = ccpSub(touchingPoint, wheel.position); CGFloat rotateAngle = -ccpToAngle(vector); CGFloat currentTouch = CC_RADIANS_TO_DEGREES(rotateAngle); float limit = 0.5; rotationValue += (currentTouch - previousTouch) * limit; } touching = YES; } Say I steer the vehicle to the far right of the screen, and want to move it to the far left, It wont start moving to the left of the screen until the rotationValue is past 0 degrees again (the wheel is in its center posistion) and is dragged past this value. Is there anyway to change the code I have above, so that movement on the wheel is recognised instantly and updates the velocity of v instantly too?

    Read the article

  • Game Center Leaderboard not dismissing

    - by FireStorm
    I was implementing Game Center into my app and all was going well except for the leaderboard done button not dismissing the leaderboard even with gameCenterControllerDidFinish added in. I call up the leaderboard with the touch of a button in the .m file as so: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint location = [touch locationInNode:self]; SKNode *node = [self nodeAtPoint:location]; if ([node.name isEqualToString:@"rankButton"]) { [self runAction:[SKAction playSoundFileNamed:@"fishtran.m4a" waitForCompletion: NO]]; GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init]; if (gameCenterController != nil) { gameCenterController.viewState = GKGameCenterViewControllerStateAchievements; UIViewController *vc = self.view.window.rootViewController; [vc presentViewController: gameCenterController animated: YES completion:nil]; } } else if ([node.name isEqualToString:@"Leaderboard"]) { GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init]; if (gameCenterController != nil) { gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards; UIViewController *vc = self.view.window.rootViewController; [vc presentViewController: gameCenterController animated: YES completion:nil]; } } ... and then I added thegameCenterControllerDidFinish immediately after as so: - (void)gameCenterControllerDidFinish:(GKGameCenterViewController*)gameCenterController { UIViewController *vc = self.view.window.rootViewController; [vc dismissViewControllerAnimated:YES completion:nil]; } and the done button still doesn't work and i haven't been able to find any solutions. And yes, I do have GKGameCenterControllerDelegate in my .h file. Any help would be greatly appreciated, Thanks!

    Read the article

  • Rotating wheel with touch adding velocity

    - by Lewis
    I have a wheel control in a game which is setup like so: - (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint location = [touch locationInView:[touch view]]; location = [[CCDirector sharedDirector] convertToGL:location]; if (CGRectContainsPoint(wheel.boundingBox, location)) { CGPoint firstLocation = [touch previousLocationInView:[touch view]]; CGPoint location = [touch locationInView:[touch view]]; CGPoint touchingPoint = [[CCDirector sharedDirector] convertToGL:location]; CGPoint firstTouchingPoint = [[CCDirector sharedDirector] convertToGL:firstLocation]; CGPoint firstVector = ccpSub(firstTouchingPoint, wheel.position); CGFloat firstRotateAngle = -ccpToAngle(firstVector); CGFloat previousTouch = CC_RADIANS_TO_DEGREES(firstRotateAngle); CGPoint vector = ccpSub(touchingPoint, wheel.position); CGFloat rotateAngle = -ccpToAngle(vector); CGFloat currentTouch = CC_RADIANS_TO_DEGREES(rotateAngle); wheelRotation += (currentTouch - previousTouch) * 0.6; //limit speed 0.6 } } I update the rotation of a the wheel in the update method by doing: wheel.rotation = wheelRotation; Now once the user lets go of the wheel I want it to rotate back to where it was before but not without taking into account the velocity of the swipe the user has done. This is the bit I really can't get my head around. So if the swipe generates a lot of velocity then the wheel will carry on moving slightly in that direction until the overall force which pulls the wheel back to the starting position kicks in. Any ideas/code snippets?

    Read the article

  • Rotating wheel with touch (adding momentum and slowing down the initial rate it can be moved

    - by Lewis
    I have a wheel control in a game which is setup like so: - (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint location = [touch locationInView:[touch view]]; location = [[CCDirector sharedDirector] convertToGL:location]; if (CGRectContainsPoint(wheel.boundingBox, location)) { CGPoint firstLocation = [touch previousLocationInView:[touch view]]; CGPoint location = [touch locationInView:[touch view]]; CGPoint touchingPoint = [[CCDirector sharedDirector] convertToGL:location]; CGPoint firstTouchingPoint = [[CCDirector sharedDirector] convertToGL:firstLocation]; CGPoint firstVector = ccpSub(firstTouchingPoint, wheel.position); CGFloat firstRotateAngle = -ccpToAngle(firstVector); CGFloat previousTouch = CC_RADIANS_TO_DEGREES(firstRotateAngle); CGPoint vector = ccpSub(touchingPoint, wheel.position); CGFloat rotateAngle = -ccpToAngle(vector); CGFloat currentTouch = CC_RADIANS_TO_DEGREES(rotateAngle); wheelRotation += (currentTouch - previousTouch) * 0.6; //limit speed 0.6 } } Now once the user lets go of the wheel I want it to rotate back to where it was before but not without taking into account the momentum of the swipe the user has done. This is the bit I really can't get my head around. So if the swipe generates a lot of momentum then the wheel will carry on moving slightly in that direction until the overall force which pulls the wheel back to the starting position kicks in. Any ideas/code snippets?

    Read the article

  • How to disable multiple touches on a ScrollView and UIImage

    - by Rob
    I have a scrollview that I am loading images into that the user can touch and play a sound. However, the program is getting confused when I press one image with one finger and then another one with a different finger. It thinks you are pushing the same button again and therefore plays the sound again (so you have two of the same sounds playing at the same time even though you may have pressed a different sound button). I tried setting exclusiveTouch for each UIImage but that didn't seem to work in this case for some reason. What am I missing or is there a better way to do this? Here is some code: for creating buttons.... - (void) createButtons { CGRect myFrame = [self.outletScrollView bounds]; CGFloat gapX, gapY, x, y; int columns = 3; int myIndex = 0; int viewWidth = myFrame.size.width; int buttonsCount = [g_AppsList count]; float actualRows = (float) buttonsCount / columns; int rows = buttonsCount / columns; int buttonWidth = 100; int buttonHeight = 100; if (actualRows > rows) rows++; //set scrollview content size to hold all the glitter icons library gapX = (viewWidth - columns * buttonWidth) / (columns + 1); gapY = gapX; y = gapY; int contentHeight = (rows * (buttonHeight + gapY)) + gapY; [outletScrollView setContentSize: CGSizeMake(viewWidth, contentHeight)]; UIImage* myImage; NSString* buttonName; //center all buttons to view int i = 1, j = 1; for (i; i <= rows; i++) { //calculate gap between buttons gapX = (viewWidth - (buttonWidth * columns)) / (columns + 1); if (i == rows) { //this is the last row, recalculate gap and pitch gapX = (viewWidth - (buttonWidth * buttonsCount)) / (buttonsCount + 1); columns = buttonsCount; }//end else x = gapX; j = 1; for (j; j <= columns; j++) { //get shape name buttonName = [g_AppsList objectAtIndex: myIndex]; buttonName = [NSString stringWithFormat: @"%@.png", buttonName]; myImage = [UIImage imageNamed: buttonName]; TapDetectingImageView* imageView = [[TapDetectingImageView alloc] initWithImage: myImage]; [imageView setFrame: CGRectMake(x, y, buttonWidth, buttonHeight)]; [imageView setTag: myIndex]; [imageView setContentMode:UIViewContentModeScaleToFill]; [imageView setUserInteractionEnabled: YES]; [imageView setMultipleTouchEnabled: NO]; [imageView setExclusiveTouch: YES]; [imageView setDelegate: self]; //add button to current view [outletScrollView addSubview: imageView]; [imageView release]; x = x + buttonWidth + gapX; //increase button index myIndex++; }//end for j //increase y y = y + buttonHeight + gapY; //decrease buttons count buttonsCount = buttonsCount - columns; }//end for i } and for playing the sounds... - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { //stop playing theAudio.stop; // cancel any pending handleSingleTap messages [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(handleSingleTap) object:nil]; UITouch* touch = [[event allTouches] anyObject]; NSString* filename = [g_AppsList objectAtIndex: [touch view].tag]; NSString *path = [[NSBundle mainBundle] pathForResource: filename ofType:@"m4a"]; theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL]; theAudio.delegate = self; [theAudio prepareToPlay]; [theAudio setNumberOfLoops:-1]; [theAudio setVolume: g_Volume]; [theAudio play]; } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { BOOL allTouchesEnded = ([touches count] == [[event touchesForView:self] count]); if (allTouchesEnded) { //stop playing theAudio.stop; }//end if //stop playing theAudio.stop; }

    Read the article

  • Ho can I tell when the background is touched on a UICollectionView?

    - by Mason Cloud
    I've tried subclassing UICollectionView and overriding touchesBegan:withEvent: and hitTest:WithEvent:, and both of those methods trigger when I touch a cell. However, if I touch the space between the cells, nothing happens at all. Here's what I've created: @interface WSImageGalleryCollectionView : UICollectionView @end ..and.. @implementation WSImageGalleryCollectionView - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"Touches began"); [super touchesBegan:touches withEvent:event]; } - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { NSLog(@"Hit test reached"); return [super hitTest:point withEvent:event]; } @end

    Read the article

  • New to iPhone SDK: touchesBegan not called

    - by coriolan
    Hi, I created a very very basic iPhone app with File/New Projet/View-Based application. No NIB file there. Here is my appDelegate .h @interface MyAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; MyViewController *viewController; } .m - (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after app launch [window addSubview:viewController.view]; [window makeKeyAndVisible]; } And here is my loadView method in my controller - (void)loadView { CGRect mainFrame = [[UIScreen mainScreen] applicationFrame]; UIView *contentView = [[UIView alloc] initWithFrame:mainFrame]; contentView.backgroundColor = [UIColor redColor]; self.view = contentView; [contentView release]; } Now, in order to catch the touchesBegan event, I created a new subclass of UIView: .h @interface TouchView : UIView { } .m - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"Touch detected"); } and modified the second line in my loadView into this : TouchView *contentView = [[UIView alloc] initWithFrame:mainFrame]; Why is touchesBegan never called?

    Read the article

  • Hiding/ Showing UIPickerView

    - by aahrens
    I Have an a touchesEnded event that checks for when a UITextField is pressed. What I would like it to do is is hide/show a UIPickerView. How can this be done? - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [[event allTouches] anyObject]; if (CGRectContainsPoint([self.textField frame], [touch locationInView:self.view])) { NSString * error = @"Touched the TextField"; UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Selection!" message:error delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [errorAlert show]; //Want to show or hide UIPickerView } } I already have an allocated UIPickerView when touches occur @interface ThirdViewController : UIViewController <UITextFieldDelegate,UIPickerViewDelegate> { IBOutlet UIPickerView *pickerView; }

    Read the article

  • Passing touch events on to subviews

    - by Egil Jansson
    I have a view within a UIScrollView that loads an additional subview when the user presses a certain area. When this additional subview is visible, I want all touch events to be handled by this - and not by the scrollview. It seems like the first couple events are being handled by the subview, but then touchesCancelled is called and the scrollview takes over the touch detection. How can I make sure that the subview gets all the events as long as the movement activity is being performed on this view? This is my implementation on touchesMoved - which I thought would do the job... -(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[touches allObjects] objectAtIndex:0]; CGPoint touchPt = [touch locationInView:self]; UIView *hitView = [self hitTest:touchPt withEvent:event]; UIView *mySubView = subviewCtrl.view; if(hitView == mySubView) { [subviewCtrl.view touchesMoved:touches withEvent:event]; } else { NSLog(@"Outside of view..."); } }

    Read the article

  • iPhone hitTest broken after rotation

    - by Adam
    Hi all, I have a UIView that contains a number of CALayer subclasses. I am using the following code to detect which layer a touch event corresponds to: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint touchPoint = [touch locationInView:self]; NSLog(@"%@,%@",NSStringFromCGPoint(point),[self.layer hitTest:point].name); } This works fine until the device is rotated. When the device is rotated all current layers are removed from the superlayer, and new CALayers are created to fit the new orientation. The new layers are correctly inserted and viewable in the correct orientation. After the rotation the hitTest method consistently returns nil when clearly clicking on the newly created layers and registers for locations of layers which are incorrect. The coordinates of the hit test are correct, but no layers are found. Am I missing a function call or something after handling the rotation? Cheers, Adam

    Read the article

  • Intercept UITableView scroll touches

    - by Jonesy
    Is it possible to control when the UITableView scrolls in my own code. I am trying to get behaviour where a vertical swipe scrolls and a horizontal swipe gets passed through to my code (of which there are many example) BUT I want a DIAGONAL swipe to do nothing, i.e the UITableView should not even begin scrolling. I tried catching it in here - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView but the scrollView.contentOffset.x is always 0 so I cannot detect a horizontal movement. I also tried subclassing UITableView and implementing - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event etc.. but the UITableView (and I guess it's parent UIScrollView) start to scroll before the touches are notified? To re-iterate, I want the UITableView scrolling to be locked if a diagonal swipe is made, but to scroll vertically normally. (This behaviour can be seen in Tweetie(Twitter) for the iPhone) Thanks for any help!

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8  | Next Page >