Search Results

Search found 143 results on 6 pages for 'touchesbegan'.

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

  • 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

  • UIScrollView message handler

    - by cs221313
    Hi, all, I want to create a scroll view and put thumbnail view in that scroll view. but I can not get the touchBegan message in my program. My source code is like following. - (void)viewDidLoad { [super viewDidLoad]; NSError* error; NSString *bundleRoot = [[NSBundle mainBundle] bundlePath]; dirContents = [[[NSFileManager defaultManager] contentsOfDirectoryAtPath:bundleRoot error: &error] copy]; scrollView = [[UIScrollView alloc] initWithFrame:[[self view] bounds]]; scrollView.pagingEnabled = YES; scrollView.showsHorizontalScrollIndicator = NO; scrollView.userInteractionEnabled = YES; scrollView.clipsToBounds = YES; // default is NO, we want to restrict drawing within our scrollview scrollView.scrollEnabled = YES; [scrollView setDelegate:self]; [[self view] addSubview:scrollView]; DLog(@"scroll frame top = %d, left = %d, width = %d, height = %d", scrollView.frame.origin.x, scrollView.frame.origin.y, scrollView.frame.size.width, scrollView.frame.size.height); int i, j; UIView* onePageView = [[UIView alloc] init]; int pageNumber = 0; int iconNumber = 0; for (NSString *tString in dirContents) { if ([tString hasSuffix:@"_chess.png"]) { if(iconNumber == 9) { onePageView.tag = pageNumber + 1; [scrollView addSubview: onePageView]; onePageView = [[UIView alloc] init]; pageNumber++; iconNumber = 0; } j = iconNumber % 3; i = iconNumber / 3; const float WIDTH = 150.0; const float HEIGHT = 150.0; CGRect imageRect = CGRectMake(j * 200 + 50.0, i * 200 + 50.0, WIDTH, HEIGHT); //remove the charactors of "_chess.png". NSString* sgfName = [tString substringToIndex: tString.length - 10]; sgfName = [sgfName stringByAppendingString: @".sgf"]; ThumbnailView *thumbnailImage = [[ThumbnailView alloc] initWithFilename: sgfName frame: imageRect]; thumbnailImage.delegate = self; [thumbnailImage setImage:[UIImage imageNamed: tString]]; thumbnailImage.opaque = YES; // explicitly opaque for performance //[self.view addSubview:thumbnailImage]; [onePageView addSubview:thumbnailImage]; [thumbnailImage release]; iconNumber++; } } pageControl.numberOfPages = pageNumber + 1; pageControl.currentPage = 0; onePageView.tag = pageNumber + 1; [scrollView addSubview: onePageView]; [self layoutScrollPages]; } ThumbnailView class is like following. // // ThumbnailView.m // go // // Created by David Li on 2/18/11. // Copyright 2011 __MyCompanyName__. All rights reserved. // #import "common.h" #import "ThumbnailView.h" #import "ipad_goViewController.h" @implementation ThumbnailView @synthesize delegate; @synthesize sgfName; -(id) initWithFilename: (NSString*)filename frame: (CGRect)frame { sgfName = [[NSString alloc] initWithString: filename]; return [self initWithFrame: frame]; } - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code. self.userInteractionEnabled = YES; } return self; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [self becomeFirstResponder]; } /* refer to http://stackoverflow.com/questions/855095/how-can-i-detect-the-touch-event-of-an-uiimageview */ -(BOOL)canBecomeFirstResponder { return YES; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { DLog(@"touched"); [[self delegate] loadGame: sgfName]; } /* // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. - (void)drawRect:(CGRect)rect { // Drawing code. } */ - (void)dealloc { [super dealloc]; } @end I can not catch the touchesBegan message in my program. Can anyone help me? I stucked by this problem by couple days. Thanks so much.

    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

  • Iphone UIScrollView and multiple visible images

    - by joynes
    Hi! Im trying to implement a UIScrollView including multiple images, using paginate. The problem is that I want more then one page to be visible in the UIScrollView, but only one page should be selected. I found several solutions in which you handle touch down/up (touchesBegan and touchesEnded) myself and scrollRectToVisible, but I want to avoid this if possible. A sample solution for that can be found at: http://forums.macrumors.com/showthread.php?t=634462 I dont get why its so easy if you only need to display one page at a time in the UIScrollView , but seems really hard if you want to show more pages. Could you solve it with zooming? /Br Johannes

    Read the article

  • MkMapView setRegion animation prevents touch events on Annotation Views

    - by Vlad Gurovich
    Hi there! We have a MKmapView with a bunch of Image Annotation where each Image annotation responds to touch by overriding these methods of AnnotationView subclass: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event Our map region is updated using [MkMapView setRegion:animated:] whenever the new location is received and is far enough from the old location to make a difference. What I noticed is that if we set animated flag to YES the touches on our annotation are rarely detected(probably due to the fact that main thread is busy animating between two map regions. When we set animated flag to NO, everything is fine, but map transition may(or may not) become jerky. The question I have is whether this is an expected behavior of animated flag of [MkMapView setRegion:animated] function or whether there is a workaround for this issue. Thanks in advance

    Read the article

  • Why can I not receive touch events within my custom UIScrollView subclass?

    - by stefanosn
    i have an uiscrollview with a uiimageview inside. I subclass the uiscrollview but i can not get touches to work touchbegin does not called. What should i do to call uitouch event? what is wrong? .h #import <UIKit/UIKit.h> @interface myScrollView : UIScrollView { } @end .m #import "myScrollView.h" @implementation myScrollView - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; CGPoint location = [touch locationInView:touch.view]; if (touch.view.tag > 0) { touch.view.center = location; } NSLog(@"tag=%@", [NSString stringWithFormat:@"%i", touch.view.tag]); }

    Read the article

  • Capture Touch Event on UITableViewCell and after enter didSelectRowAdTindePath method

    - by Luca
    Hi I want to personalize my UITableView changing background when user tap on a specific cell. I've a dedicated ViewController for each cell and if I implement touchesBegan method in this viewController i can change my cell background without any problem. The problem is that the method "didSelectRowAtIndexPath" of the UITableView is no longer called. How can I call it manually? I am in another viewController and I have no access to that method. or how can propagate to the touch tableView? Thanks a lot

    Read the article

  • Differentiating Between UITouch Objects On The iPhone

    - by Jasarien
    Hey guys, I'm trying to differentiate between two (or more) UITouch objects on the iPhone. Specifically, I'd like to know the order in which the touches occurred. For instance, in my -touchesBegan:withEvent: method I get an NSSet of UITouch objects. Now I can find out how many touches there are, but, which object represents which finger? I notice the timestamp property on UITouch - is this what I'm looking for? I see how that would be useful to obtaining the last or first touch - providing the touches don't mutate... Therein lies my problem. I can use the timestamp to single out the latest touch, but then the touch that occurred first moves, and IT becomes the latest touch... At the end of this exercise, I'd like to be able to implement the "pinch" gesture to zoom in or out, etc. Any help would be greatly appreciated, thanks.

    Read the article

  • UITouches not detecting.

    - by Tony
    Hi, My UItouches is not detecting in my Slideshow nib file. What is the problem? Can anyone help? @class Slideshow; @interface RootViewController : UIViewController{ PreferencesController *preferencesController; Slideshow *slideshow;} Slideshow Implementation @implementation Slideshow - (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event { NSLog(@"touches begin"); } - (void)viewDidLoad { UIImageView *frontView = [[UIImageView alloc] initWithFrame:self.view.bounds]; frontView.backgroundColor = [UIColor blackColor]; frontView.image = [UIImage imageNamed:@"apple.png"]; frontView.userInteractionEnabled = YES; [self.view addSubview:frontView]; [frontView release]; }@end

    Read the article

  • Need multiple views to respond to a touch event in an iPhone app

    - by Joel
    Setup: I have two views that I need to respond to the touch event, and they are layered out on top of one another. View 1 is on top of View 2. View 2 is a UIWebView. View 1 is sublclassed to capture the touch event. My problem is that if I try to call the UIWebView event handlers (touchesBegan: and touchesEnded:) from within the event handlers of View 1, which is the first responder, nothing happens. However if I set View 1 to userInteractionEnabled = NO, then the touch goes through that view and is processed properly by the 2nd view. Any ideas on how I can have 2 views respond to a touch event? Unfortunately the 2nd view is a UIWebView, so I need to actually call the event handler and not a different method, etc... Thanks in advance for any advice, Joel

    Read the article

  • How can I click a button behind a transparent UIView?

    - by Sean Clark Hess
    Let's say we have a view controller with one sub view. the subview takes up the center of the screen with 100 px margins on all sides. We then add a bunch of little stuff to click on inside that subview. We are only using the subview to take advantage of the new frame ( x=0, y=0 inside the subview is actually 100,100 in the parent view). Then, imagine that we have something behind the subview, like a menu. I want the user to be able to select any of the "little stuff" in the subview, but if there is nothing there, I want touches to pass through it (since the background is clear anyway) to the buttons behind it. How can I do this? It looks like touchesBegan goes through, but buttons don't work.

    Read the article

  • change fillColor of selected CAShapeLayer

    - by Frank
    I'm trying to change the fillColor of a CAShapeLayer when the layer it's contained in is touched. I'm able to change the background color of the tapped layer like this: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { CALayer *layer = [(CALayer *)self.view.layer.presentationLayer hitTest:point]; layer = layer.modelLayer; layer.backgroundColor = [UIColor blueColor].CGColor; } This turns the background of "layer" blue as expected. My problem is how do I change the color of the CAShapelayer inside "layer"? Thanks!

    Read the article

  • Problems with CGPoint in touches event

    - by Jason
    I'm having some problems with storing variables from my touch events. The warning I get when I run this is that coord and icoord are unused, but I used them in the viewDidLoad implementation, is there a reason why this does not work? Any suggestions? -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; CGPoint icoord = [touch locationInView:touch.view]; } -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; CGPoint coord = [touch locationInView:touch.view]; } - (void)viewDidLoad { if (coord.x > icoord.x) { player.center = CGPointMake(player.center.x + 5, player.center.y); } } Thanks.

    Read the article

  • Calling a method in a view controller from a view

    - by Lakshmie
    I have to invoke a method present in a view controller who's reference is available in the view. When I try to call the method like any other method, for some reason, iPhone just ignores the call. Can somebody explain as to why this happens and also how can I go about invoking this method? In the view I have this method: -(void) touchesBegan :(NSSet *) touches withEvent:(UIEvent *)event{ NSArray* mySubViews = [self subviews]; for (UITouch *touch in touches) { int i = 0; for(; i<[mySubViews count]; i++){ if(CGRectContainsPoint([[mySubViews objectAtIndex:i] frame], [touch locationInView:self])){ break; } } if(i<[mySubViews count]){ // viewController is the reference to the View Controller. [viewController pointToSummary:[touch locationInView:self].y]; NSLog(@"Helloooooo"); break; } } } Whenever the touches event is triggered, Hellooooo gets printed in the console but the method before that is simply ignored

    Read the article

  • Can I detect if higher subview has been touched?

    - by Kevin Beimers
    I've got a big UIView that responds to touches, and it's covered with lots of little UIViews that respond differently to touches. Is it possible to touch anywhere on screen and slide around, and have each view know if it's being touched? For example, I put my finger down on the upper left and slide toward the lower right. The touchesBegan/Moved is collected by the baseView. As I pass over itemView1, itemView2, and itemView3, control passes to them. If I lift my finger while over itemView2, it performs itemView2's touchesEnded method. If I lift my finger over none of the items, it performs baseView's touchesEnded. At the moment, if I touch down on baseView, touchEnded is always baseView and the higher itemViews are ignored. Any ideas?

    Read the article

  • Querying current number of touches on screen without using events on iPhone

    - by nikhil
    I have an application that starts playing a sound when user touches the uiview and changing to different tones as the user slides the finger on the screen. The sound stops when the user lifts the finger. I am using the touchesBegan, Moved and Ended Events for this. My problem is touches Ended (and/or cancelled) is sometimes not fired properly and the sound keeps playing even after the finger is lifted from screen. So as a workaround I would like to implement a timer that would check for the number of touches on the screen and if it is zero it will check and stop the audioplayer if playing. I have been searching for some code that could get me the number of touches like UITouch *touches=[self getAllTouchesonScreen]; or something :)

    Read the article

  • Drag Rotate UIImageView by touch

    - by rockstardev
    I have an UIImageView that is a subview of an UIView. I'm trying to create a drag rotate effect with the UIImageView similar to spinning a bottle but I'm having trouble calculating the radians to rotate the image by. My code below seems like it should work because I've seen a similar calculation in Flash examples. Can anyone shed some light on what I'm doing wrong? Thanks. This is the code contained in my image view subclass: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; lastLocation = [touch locationInView:[self superview]]; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; CGPoint location = [touch locationInView:[self superview]]; CGFloat xDisplacement = location.x - lastLocation.x; CGFloat yDisplacement = location.y - lastLocation.y; CGFloat rad = atan2f(yDisplacement,xDisplacement); self.transform = CGAffineTransformMakeRotation(rad); }

    Read the article

  • iOS4.2: TouchBegan does not draw more then one circle per sensed touch

    - by Christian
    Hi all, quick question (which might be a no-brainer for most here) :) My code below should draw a circle for every time touch that is recognised but although more than ones touches are sensed only one circle will drawn up at a time. Can anyone see any obvious issues? This method sits in the XYZViewControler.m class. TouchPoint.m is the class that defines the circle. Thanks a bundle for your help and redirects. Chris - (void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *)event { NSSet * allTouches = [event allTouches]; // get all events for (UITouch * touch in touches) { TouchPoint * touchPoint = [[TouchPoint alloc] initWithFrame:CGRectMake(0, 0, circleWidth, circleWidth)]; touchPoint.center = [touch locationInView:[self view]]; touchPoint.color = [UIColor redColor]; touchPoint.backgroundColor = [UIColor whiteColor]; [[self view] addSubview: touchPoint]; [touchPoint release]; CFDictionarySetValue(touchMap, touch , touchPoint); } [[self view] setNeedsDisplay]; }

    Read the article

  • How to detect touch in triangle area

    - by Romain
    For my application, i need to divide diagonally the screen of my iphone in 4 parts and detect which of the part was touched. I am very confused because my areas are triangles and not squares and I can't find a solution to detect which of the triangle was touched... I get the touched Point with method touchesBegan, and there I'm stuck... :( How to define triangle shapes and test if it was touched? with View? layer? It could be really cool if someone could help me.

    Read the article

  • How to create a controllable flip effect (flip as far (and fast) as you drag) of an UIView

    - by allisone
    I have a card (a flashcard you could say) What I can do: On fingersweeping over the flashcard the card gets turned. It's happening by detecting touchesBegan and touchesMoved and then I do stuff like [UIView beginAnimations:@"View Flip" context:nil]; [UIView setAnimationDuration:0.5]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; if (left) { [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:self.flashCardView cache:YES]; }else{ [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:self.flashCardView cache:YES]; } What I can't do (but want to): I want to somehow drag the flip. Imagine this, you have a flashcard and you think you know the answer, you start flipping the card around because you want to see if you are correct, but then... no stop... you hesitate, turn back the card to the way it was, rethink, get the real answer and then finally flip to see that you were right to hesitate. Now I only have: once you start flipping, you can't stop it.

    Read the article

  • touchesMoved QuartzDemo application

    - by BittenApple
    I am modifying the QuartzDemo application to include swipe detection while UIView is active (a PDF page being displayed in it via Quartz). This will not work, the event never gets to the QuartzView.m because it sits under scrollview? touchesBegan works fine and I can use single tap. How can I go about with catching touchesMoved while PDF page is being displayed? I need a simple example with code that does nothing on touchesMoved, I'll build up on that later. Please keep in mind that I still want to use the UIScrollview as it is and show PDF content based on selection in that scrollview.

    Read the article

  • Maintaining last stage when rotating through CATransform3DIdentity

    - by Mikhail Naimy
    Hi. i am rotating imageview through following code.it rotates fine..but when i rotate again , Imageview goes to previous angle( which is in initial stage) and then it rotates...any one can help in this?rotationTransform has been declared as CABasicAnimation* rotationAnimation in .h file.... - (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event { UITouch *touch = [touches anyObject]; startTouchPosition = [touch locationInView:self.view]; } - (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event { UITouch *touch = [[event allTouches] anyObject]; location = [touch locationInView:self.view]; currentLocationRadians = atan2f(location.y - self.view.frame.size.height/2, location.x - self.view.frame.size.width/2); lastLocationRadians = atan2f(startTouchPosition.y - self.view.frame.size.height/2, startTouchPosition.x - self.view.frame.size.width/2); rotationTransform = CATransform3DIdentity; rotationTransform = CATransform3DRotate(rotationTransform, currentLocationRadians-lastLocationRadians + rad, 0.0, 0.0, 1.0); _imgview.layer.transform = rotationTransform; } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { rotationTransform = _imgview.layer.transform; }

    Read the article

  • Storing and retrieving CGPoints inside NSMutableArray

    - by Matt Dice
    I've looked through countless questions on here and elsewhere and cannot for the life of me figure out what I'm doing wrong. I'm trying to store an array of CGPoints as NSValues inside of an NSMutableArray named points like so on the iPhone: NSValue *point = [NSValue valueWithCGPoint:firstTouch]; NSLog(@"NSValue *point = %@", point); [points addObject:point]; NSLOG OUTPUT NSValue *point = NSPoint: {120, 221} Everything is going smooth converting from the CGPoint to NSValue. But when I try to retrieve the point I get nothing. NSValue *getPoint = [points objectAtIndex:0]; CGPoint thePoint = [getPoint CGPointValue]; NSLog(@"Point = %@", NSStringFromCGPoint(thePoint)); NSLOG OUTPUT Point = {0, 0} The points should be the same but I'm getting a null result. For testing purposes this is happening in the touchesBegan method. Does anyone have any idea where I'm going wrong? Thanks in advance.

    Read the article

  • Draw rectangle using Core Graphics with live preview

    - by mikawber
    I'm creating a simple drawing application and would like some help with drawing rectangles based on the user's touch events. I'm able to draw a rectangle using Core Graphics from the point in touchesBegan to the point in touchesEnded. This rectangle is then displayed once the touchesEnded event is fired. However, I would like to be able to do this in a 'live' fashion. Meaning, the rectangle is updated as the user drags their finger. Is this possible? Any help would be greatly appreciated, thank you!

    Read the article

  • pagecontrol indicator custom image instead of Default

    - by iphonecool
    How i change the color of pagination dots of UIPageControl? In this link the sample code is given.But it shows 3 errors for me... 1'st ERROR: Line:CGRect currentBounds = self.bounds; Error:requst for member 'bounds' in something not a structure or union Method:-(void)drawRect: 2nd Err: same error with same line in touchesBegan method. 3rd Err:@protocol PageControlDelegate @optional (void)pageControlPageDidChange:(PageControl *)pageControl; @end Error:Expected ')' before 'PageControl' .These are the three errors occurs for me...Please help me out to solve this.. I want to change the pagecontrol indicator(dot) color... Thanks & Regards, Renuga

    Read the article

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