<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Ancient Programming</title>
	
	<link>http://www.ancientprogramming.com</link>
	<description>What I encounter in my software part of life is in danger of being commented upon here</description>
	<pubDate>Mon, 09 Apr 2012 19:18:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/AncientProgramming" /><feedburner:info uri="ancientprogramming" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Animating the drag drop example</title>
		<link>http://feedproxy.google.com/~r/AncientProgramming/~3/K4FeLy1Clhs/</link>
		<comments>http://www.ancientprogramming.com/2012/04/09/animating-the-drag-drop-example/#comments</comments>
		<pubDate>Mon, 09 Apr 2012 19:09:39 +0000</pubDate>
		<dc:creator>Jacob von Eyben</dc:creator>
		
		<category><![CDATA[animation]]></category>

		<category><![CDATA[how to]]></category>

		<category><![CDATA[ios]]></category>

		<category><![CDATA[ipad]]></category>

		<category><![CDATA[iphone]]></category>

		<category><![CDATA[mac]]></category>

		<category><![CDATA[objective-c]]></category>

		<category><![CDATA[dragdrop]]></category>

		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://www.ancientprogramming.com/?p=81</guid>
		<description><![CDATA[As an update to my original ios drag drop post I have added an animation to the snap back to original position.
The changes is made to the DragContext.m file where the snapToOrignalPostion is changed to look like the following:
- (void)snapToOriginalPosition {
    [UIView animateWithDuration:0.3 animations:^() {
        [...]]]></description>
			<content:encoded><![CDATA[<p>As an update to my original <a title="ios drag drop post" href="http://www.ancientprogramming.com/2012/04/05/drag-and-drop-between-multiple-uiviews-in-ios/" target="_self">ios drag drop post</a> I have added an animation to the snap back to original position.</p>
<p>The changes is made to the DragContext.m file where the snapToOrignalPostion is changed to look like the following:</p>
<pre name="code" class="cpp">- (void)snapToOriginalPosition {
    [UIView animateWithDuration:0.3 animations:^() {
        CGPoint originalPointInSuperView = [_draggedView.superview convertPoint:_originalPosition fromView:_originalView];
        _draggedView.frame = CGRectMake(originalPointInSuperView.x, originalPointInSuperView.y, _draggedView.frame.size.width, _draggedView.frame.size.height);
    } completion:^(BOOL finished) {
        _draggedView.frame = CGRectMake(_originalPosition.x, _originalPosition.y, _draggedView.frame.size.width, _draggedView.frame.size.height);
        [_draggedView removeFromSuperview];
        [_originalView addSubview:_draggedView];
    }];
}</pre>
<p>First we animate the dragged object back to the original position (in the super view containing all drag objects and drop areas). When the animation is completed, we change the superview.</p>
<img src="http://feeds.feedburner.com/~r/AncientProgramming/~4/K4FeLy1Clhs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ancientprogramming.com/2012/04/09/animating-the-drag-drop-example/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.ancientprogramming.com/2012/04/09/animating-the-drag-drop-example/</feedburner:origLink></item>
		<item>
		<title>Drag and drop between multiple UIViews in iOS</title>
		<link>http://feedproxy.google.com/~r/AncientProgramming/~3/MzQs7I1Gn8k/</link>
		<comments>http://www.ancientprogramming.com/2012/04/05/drag-and-drop-between-multiple-uiviews-in-ios/#comments</comments>
		<pubDate>Thu, 05 Apr 2012 15:43:28 +0000</pubDate>
		<dc:creator>Jacob von Eyben</dc:creator>
		
		<category><![CDATA[how to]]></category>

		<category><![CDATA[ios]]></category>

		<category><![CDATA[ipad]]></category>

		<category><![CDATA[iphone]]></category>

		<category><![CDATA[objective-c]]></category>

		<category><![CDATA[dragdrop]]></category>

		<category><![CDATA[example]]></category>

		<category><![CDATA[uiview]]></category>

		<guid isPermaLink="false">http://www.ancientprogramming.com/?p=63</guid>
		<description><![CDATA[This is an example showing how to drag and and drop UIViews between other UIViews in iOS.
The example is broken into the following four and a half step.
Example broken into steps
1. register a UIPanGestureRecognizer to be able to get drag panning events  (in our case drag events).
2. detect if the panning started above the view [...]]]></description>
			<content:encoded><![CDATA[<p>This is an example showing how to drag and and drop UIViews between other UIViews in iOS.</p>
<p><div id="attachment_66" class="wp-caption alignnone" style="width: 310px"><a href="http://www.ancientprogramming.com/wp-content/uploads/2012/04/dragdropillustration1.png"><img class="size-medium wp-image-66" title="dragdropviewstack" src="http://www.ancientprogramming.com/wp-content/uploads/2012/04/dragdropillustration1-300x62.png" alt="Illustrates the drag and drop UIView stack" width="300" height="62" /></a><p class="wp-caption-text">Illustrates the drag and drop UIView stack</p></div></p>
<p>The example is broken into the following four and a half step.</p>
<p><strong>Example broken into steps</strong><br />
1. register a UIPanGestureRecognizer to be able to get drag panning events  (in our case drag events).<br />
2. detect if the panning started above the view we would like to drag.<br />
3. move the view according to the panning - which means removing the object from the view we would like to drag it from.<br />
4. when dragging ends, drop the view onto the view below the dragged object.<br />
4.a. optionally reset the dragged object, if the object is dragged onto a view which we don&#8217;t consider as a valid drop view.<br />
<div><script type="text/javascript"><!--
google_ad_client = "pub-3557368819388454";
/* 728x90, created 01/03/08 */
google_ad_slot = "3206414101";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><br />
In my example I have created a more or less generic DragDropManager, which is responsible for actually handling the UIViews objects we allow to drag &#8216;n drop and the UIVeiws we allow to drop onto.</p>
<p><strong>Step 1</strong><br />
The manager registers the draggable objects and drop areas and takes care of detecting when a object should be dragged and dropped. This is done by receiving pan events from the UIPanGestureRecognizer. I recommend registering the gesture recognizer to a UIView having a frame covering the entire drag and drop area, because if you bind the recognizer to the actual draggable objects, you will loose the pan sequence as soon as you change super view for the dragged object (and changing super view is the hole point of dragging objects between UIViews).</p>
<pre  name="code" class="cpp">@implementation DragDropBetweenViewsViewController
...
- (void)viewDidLoad {
    [super viewDidLoad];
    _viewA = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
    [_viewA setBackgroundColor:[UIColor greenColor]];
    _viewA.tag = 1;
    _viewB = [[UIView alloc] initWithFrame:CGRectMake(0, 220, 320, 200)];
    [_viewB setBackgroundColor:[UIColor yellowColor]];
    _viewB.tag = 2;

    [[self view] addSubview:_viewA];
    [[self view] addSubview:_viewB];
    //[[self view] addSubview:_viewB];

    //add elements to drag and drop
    UIView *dragDropView1 = [[[UIView alloc] initWithFrame:CGRectMake(100, 100, 50, 50)] autorelease];
    UIView *dragDropView2 = [[[UIView alloc] initWithFrame:CGRectMake(100, 100, 50, 50)] autorelease];
    [_viewA addSubview:dragDropView1];
    [_viewB addSubview:dragDropView2];
    [dragDropView1 setBackgroundColor:[UIColor redColor]];
    [dragDropView2 setBackgroundColor:[UIColor blueColor]];
    NSMutableArray *draggableSubjects = [[NSMutableArray alloc] initWithObjects:dragDropView1, dragDropView2, nil];
    NSMutableArray *droppableAreas = [[NSMutableArray alloc] initWithObjects:_viewA, _viewB, nil];
    _dragDropManager = [[DragDropManager alloc] initWithDragSubjects:draggableSubjects andDropAreas:droppableAreas];
    [draggableSubjects release];
    [droppableAreas release];

    UIPanGestureRecognizer * uiTapGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:_dragDropManager action:@selector(dragging:)];
    [[self view] addGestureRecognizer:uiTapGestureRecognizer];
    [uiTapGestureRecognizer release];
}
...
@end</pre>
<p><strong>Step 2</strong><br />
The manager switches on the different states of the UIPanGestureRecognizer and detects if a panning  starts on one of our dragSubjects. If so we store the DragContext containing the dragged view and the starting point (to be able to snap back to the offset in case the drag ends outside a drop zone). At the same time we change superview for the dragged object, by attaching it to the UIView spanning the entire area. This is done to ensure our UIView is shown above all other subviews and hence is visible during the entire drag drop session.</p>
<p><strong>Step 3</strong><br />
During the drag process we simply move the object according to the coordinates of the UIGestureRecognizer.</p>
<p><strong>Step 4</strong><br />
When the panning ends (the UIGestureRecognizer is in state UIGestureRecognizerStateEnded), we check to see if the dropped view is above any registered drop areas. If so, we add the dragged UIView as a subview of the detected drop area.</p>
<p><strong>Step 4.a.</strong><br />
If we don&#8217;t recognize a valid drop area beneath our dragged view, we snap the dragged UIView back to its original superview and position.<br />
<!-- WSA: ad in context leaderboard not shown: too many ads --><br />
The DragManager code can be seen here:</p>
<pre name="code" class="cpp">@implementation DragDropManager {

    NSArray *_dragSubjects;
    NSArray *_dropAreas;
    DragContext *_dragContext;
}

@synthesize dragContext = _dragContext;
@synthesize dropAreas = _dropAreas;

- (id)initWithDragSubjects:(NSArray *)dragSubjects andDropAreas:(NSArray *)dropAreas {
    self = [super init];
    if (self) {
        _dropAreas = [dropAreas retain];
        _dragSubjects = [dragSubjects retain];
        _dragContext = nil;
    }

    return self;
}

- (void)dealloc {
    [_dragSubjects release];
    [_dragContext release];
    [_dropAreas release];
    [super dealloc];
}

- (void)dragObjectAccordingToGesture:(UIPanGestureRecognizer *)recognizer {
    if (self.dragContext) {
        CGPoint pointOnView = [recognizer locationInView:recognizer.view];
        self.dragContext.draggedView.center = pointOnView;
    }
}

- (void)dragging:(id)sender {
    UIPanGestureRecognizer *recognizer = (UIPanGestureRecognizer *) sender;
    switch (recognizer.state) {
        case UIGestureRecognizerStateBegan: {
            for (UIView *dragSubject in _dragSubjects) {
                CGPoint pointInSubjectsView = [recognizer locationInView:dragSubject];
                BOOL pointInSideDraggableObject = [dragSubject pointInside:pointInSubjectsView withEvent:nil];
                NSLog(@"point%@ %@ subject%@", NSStringFromCGPoint(pointInSubjectsView), pointInSideDraggableObject ? @"inside" : @"outside", NSStringFromCGRect(dragSubject.frame));
                if (pointInSideDraggableObject) {
                    NSLog(@"started dragging an object");
                    self.dragContext = [[[DragContext alloc] initWithDraggedView:dragSubject] autorelease];
                    [dragSubject removeFromSuperview];
                    [recognizer.view addSubview:dragSubject];
                    [self dragObjectAccordingToGesture:recognizer];
                } else {
                    NSLog(@"started drag outside drag subjects");
                }
            }
            break;
        }
        case UIGestureRecognizerStateChanged: {
            [self dragObjectAccordingToGesture:recognizer];
            break;
        }
        case UIGestureRecognizerStateEnded: {
            if (self.dragContext) {
                UIView *viewBeingDragged = self.dragContext.draggedView;
                NSLog(@"ended drag event");
                CGPoint centerOfDraggedView = viewBeingDragged.center;
                BOOL droppedViewInKnownArea = NO;
                for (UIView *dropArea in self.dropAreas) {
                    CGPoint pointInDropView = [recognizer locationInView:dropArea];
                    NSLog(@"tag %li pointInDropView %@ center of dragged view %@", dropArea.tag, NSStringFromCGPoint(pointInDropView), NSStringFromCGPoint(centerOfDraggedView));
                    if ([dropArea pointInside:pointInDropView withEvent:nil]) {
                        droppedViewInKnownArea = YES;
                        NSLog(@"dropped subject %@ on to view tag %li", NSStringFromCGRect(viewBeingDragged.frame), dropArea.tag);
                        [viewBeingDragged removeFromSuperview];
                        [dropArea addSubview:viewBeingDragged];
                        //change origin to match offset on new super view
                        viewBeingDragged.frame = CGRectMake(pointInDropView.x - (viewBeingDragged.frame.size.width / 2), pointInDropView.y - (viewBeingDragged.frame.size.height / 2), viewBeingDragged.frame.size.width, viewBeingDragged.frame.size.height);
                    }
                }

                if (!droppedViewInKnownArea) {
                    NSLog(@"release draggable object outside target views - snapping back to last known location");
                    [self.dragContext snapToOriginalPosition];
                }

                self.dragContext = nil;
            } else {
                NSLog(@"Nothing was being dragged");
            }
            break;
        }
    }
}
@end</pre>
<p>The DragContext containing the dragged view and the original position and view</p>
<pre name="code" class="cpp">#import "DragContext.h"

@implementation DragContext {

    UIView *_draggedView;
    CGPoint _originalPosition;
    UIView *_originalView;
}
@synthesize draggedView = _draggedView;

- (id)initWithDraggedView:(UIView *)draggedView {
    self = [super init];
    if (self) {
        _draggedView = [draggedView retain];
        _originalPosition = _draggedView.frame.origin;
        _originalView = [_draggedView.superview retain];
    }

    return self;
}

- (void)dealloc {
    [_draggedView release];
    [_originalView release];
    [super dealloc];
}

- (void)snapToOriginalPosition {
    [_draggedView removeFromSuperview];
    [_originalView addSubview:_draggedView];
    _draggedView.frame = CGRectMake(_originalPosition.x, _originalPosition.y, _draggedView.frame.size.width, _draggedView.frame.size.height);
}
@end</pre>
<p><strong>Room for improvements</strong><br />
- <del datetime="2012-04-09T19:12:21+00:00">animations should be added to show more smooth look and feel.</del>. This <a href="http://www.ancientprogramming.com/2012/04/09/animating-the-drag-drop-example/">blog post</a> demonstrates how to add animations to the snap back to orignial position.<br />
- Consider the visible order of the views when selecting draggable UIView, if multiple draggable UIViews is stacked upon each other.</p>
<img src="http://feeds.feedburner.com/~r/AncientProgramming/~4/MzQs7I1Gn8k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ancientprogramming.com/2012/04/05/drag-and-drop-between-multiple-uiviews-in-ios/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.ancientprogramming.com/2012/04/05/drag-and-drop-between-multiple-uiviews-in-ios/</feedburner:origLink></item>
		<item>
		<title>How to implement drop shadow and immerse effects for UIViews</title>
		<link>http://feedproxy.google.com/~r/AncientProgramming/~3/sR1siSdDgMk/</link>
		<comments>http://www.ancientprogramming.com/2011/12/30/uiview-drop-shadow-and-immerse-effec/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 23:43:26 +0000</pubDate>
		<dc:creator>Jacob von Eyben</dc:creator>
		
		<category><![CDATA[ios]]></category>

		<category><![CDATA[iphone]]></category>

		<category><![CDATA[mac]]></category>

		<category><![CDATA[objective-c]]></category>

		<category><![CDATA[dropshadow]]></category>

		<category><![CDATA[immerse]]></category>

		<category><![CDATA[uiview]]></category>

		<guid isPermaLink="false">http://www.ancientprogramming.com/?p=54</guid>
		<description><![CDATA[
It is pretty easy to create a drop shadow or immerse effect like this in iOS.
Here is two static helper methods I created to do the trick.
The first method is capable of dropping a shadow from one view onto another:
+ (void)dropColor:(UIColor *)dropColor from:(UIView *)dropFromView onto:(UIView *)toView x:(CGFloat)x y:(CGFloat)y {
    CGFloat cornerRadius = [...]]]></description>
			<content:encoded><![CDATA[<p><!-- WSA: ad in context leaderboard not shown: too many ads --><br />
It is pretty easy to create a drop shadow or immerse effect like this in iOS.</p>
<p>Here is two static helper methods I created to do the trick.<br />
The first method is capable of dropping a shadow from one view onto another:</p>
<pre name="code" class="cpp">+ (void)dropColor:(UIColor *)dropColor from:(UIView *)dropFromView onto:(UIView *)toView x:(CGFloat)x y:(CGFloat)y {
    CGFloat cornerRadius = [[dropFromView layer] cornerRadius];
    UIView *shadow = [[[UIView alloc] initWithFrame:dropFromView.frame] autorelease];
    [[shadow layer] setCornerRadius:cornerRadius];
    CGRect dropRect = dropFromView.frame;
    shadow.frame = CGRectMake(dropRect.origin.x + x, dropRect.origin.y + y, dropRect.size.width, dropRect.size.height);
    [shadow setBackgroundColor:dropColor];
    [toView insertSubview:shadow belowSubview:dropFromView];
}</pre>
<p>The second takes advantage of the first and creates an effect that makes it looks like the first view is immersed into the other:</p>
<pre name="code" class="cpp">+ (void)immerse:(UIView *)immerseView into:(UIView *)toView depth:(CGFloat)depth {
    CGFloat x = 0.7;
    CGFloat y = 1.4;
    [UIUtil dropColor:[UIColor darkGrayColor] from:immerseView onto:toView x:-1 * x * depth y:-1 * y * depth];
    [UIUtil dropColor:[UIColor whiteColor] from:immerseView onto:toView x:x*depth y:y*depth];
}</pre>
<p>The following effect can be added to a tableview by doing this:</p>
<pre name="code" class="cpp">
- (void)viewDidLoad {
    [super viewDidLoad];
    [[_tableView layer] setCornerRadius:5];
    [UIUtil immerse:_tableView into:self.view depth:1.5];
}
</pre>
<p><a href="http://www.ancientprogramming.com/wp-content/uploads/2011/12/dropshadow_sample.png"><img class="alignnone size-medium wp-image-58" title="dropshadow_sample" src="http://www.ancientprogramming.com/wp-content/uploads/2011/12/dropshadow_sample-300x212.png" alt="" width="300" height="212" /></a></p>
<img src="http://feeds.feedburner.com/~r/AncientProgramming/~4/sR1siSdDgMk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ancientprogramming.com/2011/12/30/uiview-drop-shadow-and-immerse-effec/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.ancientprogramming.com/2011/12/30/uiview-drop-shadow-and-immerse-effec/</feedburner:origLink></item>
		<item>
		<title>Extend UITabBarController with an arrow marker</title>
		<link>http://feedproxy.google.com/~r/AncientProgramming/~3/r0jHTbflTxE/</link>
		<comments>http://www.ancientprogramming.com/2011/09/18/extend-uitabbarcontroller-with-an-arrow-marker/#comments</comments>
		<pubDate>Sun, 18 Sep 2011 07:03:16 +0000</pubDate>
		<dc:creator>Jacob von Eyben</dc:creator>
		
		<category><![CDATA[how to]]></category>

		<category><![CDATA[ios]]></category>

		<category><![CDATA[iphone]]></category>

		<category><![CDATA[mac]]></category>

		<category><![CDATA[objective-c]]></category>

		<guid isPermaLink="false">http://www.ancientprogramming.com/?p=38</guid>
		<description><![CDATA[I have seen a couple of iPhone apps using an UITabBarController having an arrow showing just above the selected UITabBarItem as an extra visual pointer to the current visible view. At the same time the arrow moves animated between the items as the user selects them.
I decided to try implement the same effect and I [...]]]></description>
			<content:encoded><![CDATA[<p>I have seen a couple of iPhone apps using an UITabBarController having an arrow showing just above the selected UITabBarItem as an extra visual pointer to the current visible view. At the same time the arrow moves animated between the items as the user selects them.</p>
<p>I decided to try implement the same effect and I have shared my solution here.</p>
<p>The solution is made generic enough to handle any number of UITabBarItems in the UITabBarController and basically what it does is:</p>
<ul>
<li>In the viewDidAppear selector, the arrow is places above the first element. This is done by calculating the size and location (also known as the CGRect) of the first UITabBarItem. Then a new UIImageView is created and positioned centered and above the UITabBarItem. Again some math is used to find the offset to use for the newly created UIImageView</li>
<li>In the didSelectItem a transition is used to animate the movement of the arrow between the items as they are selected.</li>
</ul>
<table border="0">
<tr>
<td><a href="http://www.ancientprogramming.com/wp-content/uploads/2011/09/tabbarmarker1.png"><img src="http://www.ancientprogramming.com/wp-content/uploads/2011/09/tabbarmarker1-300x227.png" alt="" title="tabbarmarker1" width="300" height="227" class="alignnone size-medium wp-image-42" /></a></td>
<td><a href="http://www.ancientprogramming.com/wp-content/uploads/2011/09/tabbarmarker2.png"><img src="http://www.ancientprogramming.com/wp-content/uploads/2011/09/tabbarmarker2-300x227.png" alt="" title="tabbarmarker2" width="300" height="227" class="alignnone size-medium wp-image-43" /></a></td>
</tr>
</table>
<p><!-- WSA: ad in context leaderboard not shown: too many ads --></p>
<p>My CustomUITabBarController.h and CustomUITabBarController.m files looks like this:</p>
<pre name="code" class="cpp">
@interface CustomUITabBarController : UITabBarController {
@private
    UIImageView *_imageView;
}
@end
</pre>
<p>The actual implementation looks like follows:</p>
<pre name="code" class="cpp">
@interface CustomUITabBarController ()
@property(nonatomic, retain) UIImageView *imageView;
@end

@implementation CustomUITabBarController

@synthesize imageView = _imageView;

- (CGRect) rectForItem:(UITabBarItem *)item {
    NSUInteger itemsInTabBar = [self.tabBar.items count];

    CGSize itemSize = CGSizeMake(self.tabBar.frame.size.width / itemsInTabBar, self.tabBar.frame.size.height);
    //find current selected item index
    int currentIndexSelected = 0;
    //if the item is nil, we keep the index at zero (selects the first element)
    if (item != nil) {
        for (int i = 0; i < itemsInTabBar; i++) {
            UITabBarItem *currentItem = [self.tabBar.items objectAtIndex:(NSUInteger) i];
            if (currentItem == item) {
                currentIndexSelected = i;
            }
        }
    }
    //construct the rect that defines the current selected item
    return CGRectMake(lrint(currentIndexSelected * itemSize.width), itemSize.height, itemSize.width, itemSize.height);
}

- (CGRect)getRectForImage:(UIImage *)markerImage andTabPosition:(CGRect)itemRect {
    CGFloat windowHeight = [UIScreen mainScreen].bounds.size.height;
    CGRect markerImageRect = CGRectMake(itemRect.origin.x + lrint(itemRect.size.width / 2) - lrint(markerImage.size.width / 2), windowHeight - itemRect.size.height - markerImage.size.height, markerImage.size.width, markerImage.size.height);
    return markerImageRect;
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];  //To change the template use AppCode | Preferences | File Templates.
    UIImage * markerImage = [UIImage imageNamed:@"tabMarker.png"];
    CGRect firstItemRect = [self rectForItem:nil];
    CGRect markerImageRect = [self getRectForImage:markerImage andTabPosition:firstItemRect];
    _imageView = [[UIImageView alloc] initWithFrame:markerImageRect];
    _imageView.image = markerImage;
    [self.view addSubview:_imageView];
}

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
    CGRect selectedItemRect = [self rectForItem:item];

    [UIView beginAnimations:@"move tabMarker" context:nil];
    [UIView setAnimationDuration:0.3f];
    _imageView.transform = CGAffineTransformMakeTranslation(selectedItemRect.origin.x,0);
    [UIView commitAnimations];
}
...
@end
</pre>
<img src="http://feeds.feedburner.com/~r/AncientProgramming/~4/r0jHTbflTxE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ancientprogramming.com/2011/09/18/extend-uitabbarcontroller-with-an-arrow-marker/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.ancientprogramming.com/2011/09/18/extend-uitabbarcontroller-with-an-arrow-marker/</feedburner:origLink></item>
		<item>
		<title>Logging sql statements and parameters using hibernate</title>
		<link>http://feedproxy.google.com/~r/AncientProgramming/~3/ytiOQkVrv2Q/</link>
		<comments>http://www.ancientprogramming.com/2009/11/12/logging-sql-statements-and-parameters-using-hibernate/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 20:32:44 +0000</pubDate>
		<dc:creator>Jacob von Eyben</dc:creator>
		
		<category><![CDATA[how to]]></category>

		<category><![CDATA[java]]></category>

		<category><![CDATA[hibernate]]></category>

		<category><![CDATA[logdriver]]></category>

		<category><![CDATA[logging]]></category>

		<category><![CDATA[runtime]]></category>

		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.ancientprogramming.com/?p=33</guid>
		<description><![CDATA[If you need to log sql statements using hibernate you can turn debug on for the org.hibernate.sql logger.
That will log all sql statement, but the actual parameter values will not be logged.
To log the values bound to the hibernate prepared statements, you can turn on trace for the org.hibernate.type logger.
Unfortunately (apparently because of perfomance) the [...]]]></description>
			<content:encoded><![CDATA[<p><!-- WSA: ad in context leaderboard not shown: too many ads -->If you need to log sql statements using hibernate you can turn debug on for the org.hibernate.sql logger.<br />
That will log all sql statement, but the actual parameter values will not be logged.</p>
<p>To log the values bound to the hibernate prepared statements, you can turn on trace for the org.hibernate.type logger.</p>
<p>Unfortunately (apparently because of perfomance) the value of the org.hibernate.type logger is evaulated once in a static block, and cached, see:<a href="http://www.docjar.com/html/api/org/hibernate/type/EnumType.java.html" target="_blank"> EnumType.java</a>.</p>
<p>That prevents you from turning the log on and off during runtime using a simple jsp page like the <a href="http://ananthkannan.blogspot.com/2009/10/how-to-change-log-levels-on-fly-using.html" target="_blank">log4jAdmin.jsp</a>. Note that if it were possible you still had to add trace to the page as debug is currently the lowest value.</p>
<p>Of course there must be a reason why the hibernate implementation are caching the value of the org.hibernate.type logger, but I believe it is still valuable to be able to turn on sql logging with parameters at runtime.</p>
<p>For that purpose I came across the <a href="http://rkbloom.net/logdriver/" target="_blank">logDriver</a>. A simple database driver written by Ryan Bloom, that is wrapping an existing jdbc driver.</p>
<p>To use the logdriver all you have to do is set the driver and connection url as follows:</p>
<p>driver:net.rkbloom.logdriver.LogDriver<br />
url:jdbc:log_real_driver_class:real_jdbc_connection_url</p>
<p>Now you can turn on logging by setting the net.rkbloom.logdriver logger to debug.</p>
<img src="http://feeds.feedburner.com/~r/AncientProgramming/~4/ytiOQkVrv2Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ancientprogramming.com/2009/11/12/logging-sql-statements-and-parameters-using-hibernate/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.ancientprogramming.com/2009/11/12/logging-sql-statements-and-parameters-using-hibernate/</feedburner:origLink></item>
		<item>
		<title>Any good maven support for Google Appengine?</title>
		<link>http://feedproxy.google.com/~r/AncientProgramming/~3/XS_2mtQk0Nc/</link>
		<comments>http://www.ancientprogramming.com/2009/06/05/any-good-maven-support-for-google-appengine/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 14:18:44 +0000</pubDate>
		<dc:creator>Jacob von Eyben</dc:creator>
		
		<category><![CDATA[java]]></category>

		<category><![CDATA[maven]]></category>

		<category><![CDATA[appengine]]></category>

		<category><![CDATA[google-appengine]]></category>

		<guid isPermaLink="false">http://www.ancientprogramming.com/?p=29</guid>
		<description><![CDATA[Yesterday I created a appengine project testing the JPA/Spring/Wicket stack.
This was created using the build.xml file found in the appengine documentation. It all worked fine, but I would like to build my project using maven so I started looking for a good maven plugin.
I found this blog talking about what features a good plugin should [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I created a appengine project testing the JPA/Spring/Wicket stack.</p>
<p>This was created using the <a href="http://code.google.com/appengine/docs/java/tools/ant.html">build.xml </a>file found in the appengine documentation. It all worked fine, but I would like to build my project using maven so I started looking for a good maven plugin.</p>
<p>I found this <a href="http://www.sonatype.com/people/2009/04/my-google-app-engine-maven-plugin-wishlist/">blog</a> talking about what features a good plugin should contain and a guy from the <a href="http://www.kindleit.net/">kindleit</a> company claiming that they actually had implemented a <a href="http://code.google.com/p/maven-gae-plugin">maven-gae-plugin</a> capable of executing most of these tasks.</p>
<p>Unfortunately I ran into several problems using this plugin, hence I have created an <a href=" http://code.google.com/p/maven-gae-plugin/issues/detail?id=4">issue</a>.</p>
<p>Untill these tasks in the issue has been fixed I would like to use another plugin.<br />
Can anybody guide me in the direction of a more stable plugin?</p>
<img src="http://feeds.feedburner.com/~r/AncientProgramming/~4/XS_2mtQk0Nc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ancientprogramming.com/2009/06/05/any-good-maven-support-for-google-appengine/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.ancientprogramming.com/2009/06/05/any-good-maven-support-for-google-appengine/</feedburner:origLink></item>
		<item>
		<title>Howto setup smooth ssh access</title>
		<link>http://feedproxy.google.com/~r/AncientProgramming/~3/w4YIxA8c3iU/</link>
		<comments>http://www.ancientprogramming.com/2008/10/24/howto-setup-smooth-ssh-access/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 20:59:21 +0000</pubDate>
		<dc:creator>Jacob von Eyben</dc:creator>
		
		<category><![CDATA[how to]]></category>

		<category><![CDATA[ssh]]></category>

		<category><![CDATA[.ssh/config]]></category>

		<category><![CDATA[howto]]></category>

		<category><![CDATA[ssh-keygen]]></category>

		<guid isPermaLink="false">http://www.ancientprogramming.com/2008/10/24/howto-setup-smooth-ssh-access/</guid>
		<description><![CDATA[Everytime I have a new machine or a new ssh access to setup I forgot how to configure the access so I don&#8217;t have to type the username each time (if I login with a different user).
At the same time I would like to use a private rsa key. So here goes a note to [...]]]></description>
			<content:encoded><![CDATA[<p><!-- WSA: ad in context square-right not shown: too many ads -->Everytime I have a new machine or a new ssh access to setup I forgot how to configure the access so I don&#8217;t have to type the username each time (if I login with a different user).<br />
At the same time I would like to use a private rsa key. So here goes a note to myself and other scatter brains <img src='http://www.ancientprogramming.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Instead of always have to type username and password like this:</p>
<pre>[jeyben@machine ~]$ ssh username@www.ancientprogramming.com
Password:
Last login: Fri Oct 24 16:31:03 2008 from somewhere
[username@servername ~]$</pre>
<p>I would like to just do the following:</p>
<pre>[jeyben@machine ~]$ ssh ancientprogramming
Last login: Fri Oct 24 16:31:03 2008 from somewhere
[username@servername ~]$</pre>
<h3>Create and use a public/private key pair</h3>
<p><strong>Client</strong></p>
<pre>$ ssh-keygen -t rsa
$ scp ~/.ssh/id_rsa.pub www.ancientprogramming.com:~</pre>
<p><strong>Server</strong></p>
<pre>$ cat ~/id_rsa.pub &gt;&gt; .ssh/authorized_keys</pre>
<h3>Modify .ssh/config</h3>
<pre>Host ancientprogramming
  User &lt;username&gt;
  Port 22
  HostName www.ancientprogramming.com
  LocalForward 3307 localhost:3306 (setup a localforward for the default mysql port)</pre>
<p><!-- WSA: ad in context leaderboard not shown: too many ads --></p>
<img src="http://feeds.feedburner.com/~r/AncientProgramming/~4/w4YIxA8c3iU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ancientprogramming.com/2008/10/24/howto-setup-smooth-ssh-access/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.ancientprogramming.com/2008/10/24/howto-setup-smooth-ssh-access/</feedburner:origLink></item>
		<item>
		<title>Fixedformat4j now supports primitive datatypes as well as innerclasses</title>
		<link>http://feedproxy.google.com/~r/AncientProgramming/~3/uKx7UXjCuZk/</link>
		<comments>http://www.ancientprogramming.com/2008/10/16/fixedformat4j-now-supports-primitive-datatypes-as-well-as-innerclasses/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 19:02:49 +0000</pubDate>
		<dc:creator>Jacob von Eyben</dc:creator>
		
		<category><![CDATA[fixedformat4j]]></category>

		<category><![CDATA[java]]></category>

		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://www.ancientprogramming.com/2008/10/16/fixedformat4j-now-supports-primitive-datatypes-as-well-as-innerclasses/</guid>
		<description><![CDATA[Support for primitive datatypes is added to the latest 1.2.1 release of fixedformat4j. I would like to thank Marcos Lois Bermúdez for contributing with this extension. The latest release can be downloaded here.
The same 1.2.1 release also fixed the bug that made it impossible to use annotate and format static nested classes and inner classes
The [...]]]></description>
			<content:encoded><![CDATA[<p>Support for primitive datatypes is added to the latest 1.2.1 release of fixedformat4j. I would like to thank Marcos Lois Bermúdez for contributing with this extension. The latest release can be downloaded <a href="http://code.google.com/p/fixedformat4j/downloads/list">here</a>.</p>
<p>The same 1.2.1 release also fixed the bug that made it impossible to use annotate and format static nested classes and inner classes</p>
<p>The complete <a href="http://fixedformat4j.ancientprogramming.com/changes-report.html">changelist</a> can be found on the <a href="http://fixedformat4j.ancientprogramming.com/">project website</a>.</p>
<p>In a few days the release should be available from ibiblio.</p>
<p>I encourage all users of fixedformat4j to contribute or create <a href="http://code.google.com/p/fixedformat4j/issues/list">issues</a> if they find a bug or would like new features to be added.<br />
<!-- WSA: ad in context leaderboard not shown: too many ads --></p>
<img src="http://feeds.feedburner.com/~r/AncientProgramming/~4/uKx7UXjCuZk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ancientprogramming.com/2008/10/16/fixedformat4j-now-supports-primitive-datatypes-as-well-as-innerclasses/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.ancientprogramming.com/2008/10/16/fixedformat4j-now-supports-primitive-datatypes-as-well-as-innerclasses/</feedburner:origLink></item>
		<item>
		<title>Automatically reconnect to NAS under Mac OS X</title>
		<link>http://feedproxy.google.com/~r/AncientProgramming/~3/blTDPxJZHf8/</link>
		<comments>http://www.ancientprogramming.com/2008/06/27/automatically-reconnect-to-nas-under-mac-os-x/#comments</comments>
		<pubDate>Fri, 27 Jun 2008 21:21:20 +0000</pubDate>
		<dc:creator>Jacob von Eyben</dc:creator>
		
		<category><![CDATA[how to]]></category>

		<category><![CDATA[mac]]></category>

		<category><![CDATA[automator]]></category>

		<category><![CDATA[connect]]></category>

		<category><![CDATA[nas]]></category>

		<category><![CDATA[os x]]></category>

		<category><![CDATA[reconnect]]></category>

		<category><![CDATA[remount]]></category>

		<guid isPermaLink="false">http://www.ancientprogramming.com/2008/06/27/automatically-reconnect-to-nas-under-mac-os-x/</guid>
		<description><![CDATA[Mac OS X doesn&#8217;t remount network drives when booted. You have to do this yourselves.
You can easily automate this by creating an application using the automator and add it to your login items.

You automator script should contain two items:

Get Specified Servers
Connect to Servers

Save the script as an application and put it into login items for [...]]]></description>
			<content:encoded><![CDATA[<p>Mac OS X doesn&#8217;t remount network drives when booted. You have to do this yourselves.</p>
<p>You can easily automate this by creating an application using the automator and add it to your login items.</p>
<p style="text-align: center"><a href="http://www.ancientprogramming.com/wp-content/uploads/2008/06/automator-connect.gif" title="Automator - create application"><img src="http://www.ancientprogramming.com/wp-content/uploads/2008/06/automator-connect.gif" alt="Automator - create application" height="220" width="460" /></a></p>
<p>You automator script should contain two items:</p>
<ul>
<li>Get Specified Servers</li>
<li>Connect to Servers</li>
</ul>
<p>Save the script as an application and put it into login items for your user account. This will execute your small application each time you login and you should be reconnected to your NAS on startup.</p>
<img src="http://feeds.feedburner.com/~r/AncientProgramming/~4/blTDPxJZHf8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ancientprogramming.com/2008/06/27/automatically-reconnect-to-nas-under-mac-os-x/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.ancientprogramming.com/2008/06/27/automatically-reconnect-to-nas-under-mac-os-x/</feedburner:origLink></item>
		<item>
		<title>Fixedformat4j 1.2.0 released</title>
		<link>http://feedproxy.google.com/~r/AncientProgramming/~3/tkQbDV2v3H4/</link>
		<comments>http://www.ancientprogramming.com/2008/06/12/fixedformat4j-120-released/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 21:07:44 +0000</pubDate>
		<dc:creator>Jacob von Eyben</dc:creator>
		
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.ancientprogramming.com/2008/06/12/fixedformat4j-120-released/</guid>
		<description><![CDATA[This evening I released a new version of fixedformat4j containing improved error reporting when failing to parse data using the FixedFormatManager.
The lack of good error reporting was a bit of a pain. It was not easy to see where in the parsing failed and it was not possible to get a complete list of format [...]]]></description>
			<content:encoded><![CDATA[<p>This evening I released a new version of fixedformat4j containing improved error reporting when failing to parse data using the FixedFormatManager.</p>
<p>The lack of good error reporting was a bit of a pain. It was not easy to see where in the parsing failed and it was not possible to get a complete list of format instructions.</p>
<p>A new ParseException is now thrown which contains the nessesary information.</p>
<p>See example of the new and improved stacktrace:</p>
<pre name="code" class="java">
com.ancientprogramming.fixedformat4j.format.ParseException: failed to parse 'barfooba' at offset 16 as java.util.Date from 'foobarfoobarfoobarfoobar'. Got format instructions from com.ancientprogramming.fixedformat4j.format.impl.MyRecord.getDateData. See details{FormatContext{offset=16, dataType=java.util.Date, formatter=com.ancientprogramming.fixedformat4j.format.impl.ByTypeFormatter}, FormatInstructions{length=8, alignment=LEFT, paddingChar=' ', fixedFormatPatternData=FixedFormatPatternData{pattern='yyyyMMdd'}, fixedFormatBooleanData=FixedFormatBooleanData{trueValue='T', falseValue='F'}, fixedFormatNumberData=FixedFormatNumberData{signing=NOSIGN, positiveSign='+', negativeSign='-'}, fixedFormatDecimalData=FixedFormatDecimalData{decimals=2, useDecimalDelimiter=false, decimalDelimiter='.'}}}
 at com.ancientprogramming.fixedformat4j.format.impl.FixedFormatManagerImpl.readDataAccordingFieldAnnotation(FixedFormatManagerImpl.java:179)
 at com.ancientprogramming.fixedformat4j.format.impl.FixedFormatManagerImpl.load(FixedFormatManagerImpl.java:70)</pre>
<p>Feel free to <a href="http://code.google.com/p/fixedformat4j/downloads/list">download</a> the latest version and take a look at the <a href="http://fixedformat4j.ancientprogramming.com/changes-report.html">changelist</a>.</p>
<img src="http://feeds.feedburner.com/~r/AncientProgramming/~4/tkQbDV2v3H4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ancientprogramming.com/2008/06/12/fixedformat4j-120-released/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.ancientprogramming.com/2008/06/12/fixedformat4j-120-released/</feedburner:origLink></item>
	</channel>
</rss>

