Delta Engine

Delta Engine Blog

All about multiplatform and game development

Easter Eggs Out Now!

Passing touch events from UIScrollView to the parent UIViewController

This post is about Objective-C iPhone stuff!

Just because this took me some time to figure out (and might be useful in the future or for other people): In the iPhone SDK a UIScrollView class will eat up all touch events (touchesBegan, touchesEnded, touchesMove, etc.) and not pass them along to your view controller where all your view logic might be (like in my case). If you know this, you can just create a new class for each ScrollView and then have some of your logic there, but in my case all I want is to pass these events along to the UIViewController (like all the other controls behave like). For this reason I just created a simple class called PassTouchesScrollView, which looks like this:
//  PassTouchesScrollView.m
//  Simple helper class for UIScrollViews that need to pass touchesBegan to the
//  UIViewController above it (see all the Controller classes here).
#import "PassTouchesScrollView.h"

@implementation PassTouchesScrollView

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
	UIView *result = nil;
	for (UIView *child in self.subviews)
		if ([child pointInside:point withEvent:event])
			if ((result = [child hitTest:point withEvent:event]) != nil)
				break;

	return result;
}

- (void)dealloc
{
    [super dealloc];
}

@end

Note: This is only useful if you really do not need any touch events in the UIScrollView because even the scrolling drag touch events will be ignored and send to the UIViewController. If you want to be more selective, e.g. just pass the touchesEnded event on to the parents via:
-(void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event
{
	// Pass to parent
	[super touchesEnded:touches withEvent:event];
	[self.nextResponder touchesEnded:touches withEvent:event];
}

References: Found helpful tips on StackOverflow and other sites (including this apple support forum).

How to preload website images

Pretty quick tip because it was a little annoying that the huge background on this site took so long to load sometimes and reading the text was not very easy until all the panel images were loaded too. To make sure that the panel images for all the content are loaded first I just had to add this to the main css file:
#preload img
{
height: 0; width: 0; border-width: 0;
position: absolute;
bottom: 0;
left: 0;
z-index: -30;
}

And then just below the html tag (in my case in the master layout file) add the following code:
BlockLeftTop, PRELOAD etc. for each image ..

  • Found on this good old article from 2006 :)
  • In case you update to Mac OS X Snow Leopard

    Yes, first of all ask yourself, wtf are you doing on a mac anyway (well, in my case Objective-C, just implemented this on the iPhone (still work in progress btw), omg).

    Well, for testing the new iPad stuff I had to install OS X 10.6.2 (Snow Leopard) on that old crappy Mac Mini I use for developing (via VNC of course) since the newest version of XCode (Visual Studio for poor mac guys) 3.2.2 (iPad beta 4) only works on the newest OS X 10.6.2.

    Anyway, after updating for over an hour, everything looked the same, but not much worked anymore. My keychain was not working anymore because all my certificates were gone, dunno why, but I needed to renew them anyway. Then in the XCode Organizer I could not connect or see any iPhone or iPod anymore, no matter how many times I reconnected the devices. On other computers everything was still working fine, the iPods, iPhones and cables were all working, the Organizer was not working anymore.

    Only after I installed the new XCode version (iPhone SDK 3.2.2 beta 4), everything was working fine again. Maybe this helps someone sometime in the future :)

    CeBIT 2010 - A quick tour around the halls

    As usual here is my post about the CeBIT. This year the conversion was big as usual, but not too much interesting stuff for game developers. Anyway, enjoy the pics.

    CeBIT 2010
    Welcome to the CeBIT 2010.

    CeBIT 2010
    The weather was pretty cold. Minus 4 degrees and lots of new snow from the night.

    CeBIT 2010
    That little cute pinguin was trapped in this server rack.

    CeBIT 2010
    Micrsoft further pushed Windows 7 and showed a little of the new Windows Phone 7 Series.

    CeBIT 2010
    Water jumping from one side to another, pretty cool.

    CeBIT 2010
    Walking trough a server room, pretty loud in here.

    CeBIT 2010
    Lots of signs for faster internet connections. Many halls had conferences and speakers about lots of topics.

    CeBIT 2010
    In the halls 14-23 it was VERY full, it took forever to get from one side to the other.

    CeBIT 2010
    This ball was floating in the air supported by coolers from the PC below it.

    CeBIT 2010
    If there are free tshirts, everyone is going nuts.

    CeBIT 2010
    This is the Intel Gaming Hall, was pretty full there too.

    CeBIT 2010
    A big Quake Live match was about to start here.

    CeBIT 2010
    Thats it for this year. Till next year then :)