Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-07-2010, 03:51 PM   #1 (permalink)
Registered Member
 
Mjsdabeast's Avatar
 
Join Date: Oct 2009
Location: Illinois
Age: 16
Posts: 94
Mjsdabeast is on a distinguished road
Question touchesbegan problem simple

I am using the touchesBegan method for whenever it is touched a new view comes up:
Code:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{
	self.view = gameOver;
	
	[gameTimer release];
	[label release];
	[levelone removeFromSuperview];
	[leveltwo removeFromSuperview];
	[levelthree removeFromSuperview];
	[levelfour removeFromSuperview];
	[levelfive removeFromSuperview];
	[self.adView pauseAdAutoRefresh];

	
}
I know it's really simple, but is there a way i can set it so it only detects touches in all of the level views(levelone, leveltwo). Because it crashes whenever I touch the screen in the gameOver view because the view is already up. This is probably very simple but i really don't know how to do it.
Mjsdabeast is offline   Reply With Quote
Old 06-08-2010, 07:14 AM   #2 (permalink)
Registered Member
 
Mjsdabeast's Avatar
 
Join Date: Oct 2009
Location: Illinois
Age: 16
Posts: 94
Mjsdabeast is on a distinguished road
Question ?????

Anyone know??
Mjsdabeast is offline   Reply With Quote
Old 06-08-2010, 07:36 AM   #3 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 50
Paul10 is on a distinguished road
Default

Quote:
Originally Posted by Mjsdabeast View Post
Anyone know??
Well, I did some looking. Now, I'm a beginner and I'm not on my mac so here goes

Get the UITouch object

//Get the UI Touch object
UITouch *touch = [[event allTouches] anyObject];

The UITouch object has a property called view. According to Apple, view = The view in which the touch initially occurred. (read-only)

That may be able to help you out.

Apple api for UITouch - UITouch Class Reference
__________________
Paul
New iPhone Developer
Paul10 is offline   Reply With Quote
Old 06-08-2010, 07:48 AM   #4 (permalink)
I like teaching
 
kwigbo's Avatar
 
Join Date: Sep 2008
Posts: 94
kwigbo is on a distinguished road
Default

What you have here seems to be a very strange way to do things. It might help if you can show more code and explain what you are trying to do. Why not make your level views respond to touches and set the parent view as a delegate so it knows which view it needs to remove?

Quote:
Originally Posted by Mjsdabeast View Post
I am using the touchesBegan method for whenever it is touched a new view comes up:
Code:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{
	self.view = gameOver;
	
	[gameTimer release];
	[label release];
	[levelone removeFromSuperview];
	[leveltwo removeFromSuperview];
	[levelthree removeFromSuperview];
	[levelfour removeFromSuperview];
	[levelfive removeFromSuperview];
	[self.adView pauseAdAutoRefresh];

	
}
I know it's really simple, but is there a way i can set it so it only detects touches in all of the level views(levelone, leveltwo). Because it crashes whenever I touch the screen in the gameOver view because the view is already up. This is probably very simple but i really don't know how to do it.
__________________
kwigbo.com - iPhone dev blog with code snippets and more.
----------------------------------------------------------------------------
iReviewFail.com Funny reviews from the iOS App Store
kwigbo is offline   Reply With Quote
Old 06-08-2010, 03:05 PM   #5 (permalink)
Registered Member
 
Mjsdabeast's Avatar
 
Join Date: Oct 2009
Location: Illinois
Age: 16
Posts: 94
Mjsdabeast is on a distinguished road
Default

Quote:
Originally Posted by kwigbo View Post
What you have here seems to be a very strange way to do things. It might help if you can show more code and explain what you are trying to do. Why not make your level views respond to touches and set the parent view as a delegate so it knows which view it needs to remove?
It is part of the game that is in the app, but it still detects touches in the main menu and the view gameOver, which is getting called up whenever you touch the screen. So, I would like it to only work the the game part of my app, if you can even do that.
Mjsdabeast is offline   Reply With Quote
Old 06-09-2010, 07:15 AM   #6 (permalink)
I like teaching
 
kwigbo's Avatar
 
Join Date: Sep 2008
Posts: 94
kwigbo is on a distinguished road
Default

If you could explain the hierarchy of your views it would help.

Quote:
Originally Posted by Mjsdabeast View Post
It is part of the game that is in the app, but it still detects touches in the main menu and the view gameOver, which is getting called up whenever you touch the screen. So, I would like it to only work the the game part of my app, if you can even do that.
__________________
kwigbo.com - iPhone dev blog with code snippets and more.
----------------------------------------------------------------------------
iReviewFail.com Funny reviews from the iOS App Store
kwigbo is offline   Reply With Quote
Old 06-09-2010, 04:29 PM   #7 (permalink)
Registered Member
 
Mjsdabeast's Avatar
 
Join Date: Oct 2009
Location: Illinois
Age: 16
Posts: 94
Mjsdabeast is on a distinguished road
Default

Quote:
Originally Posted by kwigbo View Post
If you could explain the hierarchy of your views it would help.
Hi, thanks for responding but I figured out that it was because I was releasing a label and the gametimer I was using.
Mjsdabeast is offline   Reply With Quote
Reply

Bookmarks

Tags
crash, error, touch, touchesbegan

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 335
12 members and 323 guests
Absentia, Domele, fiftysixty, givensur, heshiming, iGamesDev, linkmx, michaelhansen, PixelInteractive, raihan.zbr, Sloshmonster
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,892
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:11 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0