<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>iNVASIVE CODE</title>
	<atom:link href="http://cocoanotes.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://cocoanotes.wordpress.com</link>
	<description>Engineering and Training</description>
	<lastBuildDate>Mon, 24 Nov 2008 12:01:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='cocoanotes.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>iNVASIVE CODE</title>
		<link>http://cocoanotes.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://cocoanotes.wordpress.com/osd.xml" title="iNVASIVE CODE" />
	<atom:link rel='hub' href='http://cocoanotes.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Toggling iPhone views using Core Animations</title>
		<link>http://cocoanotes.wordpress.com/2008/11/24/toggling-iphone-views-using-core-animations/</link>
		<comments>http://cocoanotes.wordpress.com/2008/11/24/toggling-iphone-views-using-core-animations/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 12:01:44 +0000</pubDate>
		<dc:creator>geppyp</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Core Animation]]></category>

		<guid isPermaLink="false">http://cocoanotes.wordpress.com/?p=9</guid>
		<description><![CDATA[Core Animation is a great technology. You should use it to give your app a more fluid and smooth user interface. The iPhone does not miss it and, indeed, its usage on the Apple mobile phone is much easier than on Mac OS X. I want to show you a simple example of Core Animation [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cocoanotes.wordpress.com&amp;blog=5336888&amp;post=9&amp;subd=cocoanotes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Core Animation is a great technology. You should use it to give your app a more fluid and smooth user interface. The iPhone does not miss it and, indeed, its usage on the Apple mobile phone is much easier than on Mac OS X.</p>
<p>I want to show you a simple example of Core Animation within Cocoa Touch. Many of the UIView properties are already animatable for you, so you do not need to create an explicit animation. In this case, we say that the animation is implicit in the UIView. For example, if you have a view with transparency alpha = 1.0 and you change it to 0.0, you should see during the execution an animation performing a gradual change of the alpha value. I say &#8220;you should&#8221;, because the default animation speed is quite fast, so you cannot usually appreciate it. This is due to the default value of the time duration of the animation. To modify this value, you need to explicitly refer to the animation process. So, in this case, you cannot simply change a property value of your view, but you need to adjust other parameters before the animation starts. We will see this in our example.</p>
<p>I believe you already notice in many iPhone Apps a small round button with an &#8220;i&#8221; (info button), which, when pressed, provides information about the App. Usually this information is represented on a dedicated view that appears after a very nice animation flipping between the main view and this info view. Let us reproduce this nice animation.</p>
<p>Open Xcode and create a View-Based Application. Name it ToggleTest and save it on your disk. Go to the Resources folder and double click the ToggleTestViewController.xib file to open it in Interface Builder (IB). Let us add an extra UIView object to the ToggleTestViewController.xib window (they must be two in total). Save the document and go to Xcode without closing IB. We need to add an outlet to the UiViewController for the info view. So, open the ToggleTestViewController.h file and add</p>
<p><code>IBOutlet UIView *secondaryView;</code></p>
<p>Add also this action that we need when the info button is pressed:</p>
<p><code>- (IBAction)toggleView:(id)sender;</code></p>
<p>Let us go back to IB. Connect the secondaryView outlet of the File&#8217;s Owner to the previously added UIView. Open this view and change the background color (in the Inspector View Attributes) to red. Double click the main view to open it and add a button to it. Keeping the button selected, chose Info Dark as Type in the Attribute Pane of the inspector. The button will become a small round icon containing a lower case i as shown in the following picture.</p>
<p> </p>
<p> </p>
<div id="attachment_11" class="wp-caption aligncenter" style="width: 277px"><a href="http://cocoanotes.files.wordpress.com/2008/11/fig-11.jpg"><img class="size-full wp-image-11" title="View Example" src="http://cocoanotes.files.wordpress.com/2008/11/fig-11.jpg" alt="Toggle button" width="267" height="397" /></a><p class="wp-caption-text">Toggle button</p></div>
<p> </p>
<p> </p>
<p> </p>
<p>Now, connect the -toggleView action to the info button and choose Touch Up Inside. Save and go back to Xcode. Now we add the functionality to the action.</p>
<p><code>- (IBAction)toggleView:(id)sender {</code></p>
<p><code>[UIView beginAnimations:nil context:nil];<br />
[UIView setAnimationDuration:1.0];</code></p>
<p><code> </code></p>
<p> </p>
<p><code> [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft<br />
forView:[self view]<br />
cache:YES];<br />
[[self view] addSubview:secondaryView];<br />
[UIView commitAnimations];<br />
}<br />
</code></p>
<p>To toggle back the main view, we add a touch control, so that you just tap on the screen:</p>
<p><code>- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {</code></p>
<p><code>NSSet *aSet = [event touchesForView:secondaryView];<br />
if ([aSet count] &gt; 0) {</code></p>
<p><code> </code></p>
<p><code>[UIView beginAnimations:nil context:nil];<br />
[UIView setAnimationDuration:1.0];</p>
<p>[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight<br />
forView:[self view]<br />
cache:YES];</p>
<p></code></p>
<p> </p>
<p> </p>
<p><code> [secondaryView removeFromSuperview];<br />
[UIView commitAnimations];<br />
}<br />
}</code></p>
<p>You can also play a little bit with the transition types. Try UIViewAnimationTransitionCurlUp and UIViewAnimationTransitionCurlDown.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cocoanotes.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cocoanotes.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cocoanotes.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cocoanotes.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cocoanotes.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cocoanotes.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cocoanotes.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cocoanotes.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cocoanotes.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cocoanotes.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cocoanotes.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cocoanotes.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cocoanotes.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cocoanotes.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cocoanotes.wordpress.com&amp;blog=5336888&amp;post=9&amp;subd=cocoanotes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cocoanotes.wordpress.com/2008/11/24/toggling-iphone-views-using-core-animations/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8a4dd12089541b5475223d39448c3faa?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">geppyp</media:title>
		</media:content>

		<media:content url="http://cocoanotes.files.wordpress.com/2008/11/fig-11.jpg" medium="image">
			<media:title type="html">View Example</media:title>
		</media:content>
	</item>
		<item>
		<title>How to rotate a UITabBarController</title>
		<link>http://cocoanotes.wordpress.com/2008/10/29/how-to-rotate-a-uitabbarcontroller/</link>
		<comments>http://cocoanotes.wordpress.com/2008/10/29/how-to-rotate-a-uitabbarcontroller/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 10:49:55 +0000</pubDate>
		<dc:creator>geppyp</dc:creator>
				<category><![CDATA[Cocoa Touch]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[UITabBarController]]></category>

		<guid isPermaLink="false">http://cocoanotes.wordpress.com/?p=4</guid>
		<description><![CDATA[I spent quite some time to try to understand how to rotate an application containing a tab bar controller. If you create a simple project (you can use the template Tab Bar Application offered in Xcode), you will not able to rotate the view as reported in the View Controller User Guide by Apple. I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cocoanotes.wordpress.com&amp;blog=5336888&amp;post=4&amp;subd=cocoanotes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I spent quite some time to try to understand how to rotate an application containing a tab bar controller. If you create a simple project (you can use the template Tab Bar Application offered in Xcode), you will not able to rotate the view as reported in the View Controller User Guide by Apple. I found the solution and I share it with you.</p>
<p>Let&#8217;s create a simple project. Open Xcode and chose the Tab Bar Application template in the iPhone OS group. Name it SimpleTab and save it where ever you like in your HD. Build and run it. If you rotate the iPhone (or the Simulator via Apple-Left or Right Arrow keys), it does not work: the interface keeps its portrait position.</p>
<p>Let&#8217;s add a new class to the project. Right-click the Classes group in the Groups &amp; Files pane and choose Add&#8230; -&gt; New File&#8230; Choose an NSObject subclass in the Cocoa Touch Classes group and name it MyTabBarController.</p>
<p>Open the MyTabBarController.h file and change it in this way:</p>
<p>#import &lt;UIKit/UIKit.h&gt;</p>
<p>@interface MyTabBarController : UITabBarController {</p>
<p>}<br />
@end<br />
 <br />
Notice that I am subclassing UITabBarController. Now, edit the MyTabBarController.m file and add the following method:</p>
<p>- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {<br />
return YES;<br />
}</p>
<p>Save it. We have simply created a subclass of UITabBarController able to rotate. Now, we need to tell Interface Builder to use this class, instead of its parent.</p>
<p>Double-click the MainWindow.xib file and select the Tab Bar Controller object in the MainWindow.xib window. Open the Identity Inspector and change the class name to MyTabBarController. Save it and close Interface Builder. Go back to Xcode and build and run. Now, if you try to rotate the view&#8230;&#8230; it works.</p>
<p>When you rotate the iPhone, the content of each view is not correctly displayed. You have to play with the autosizing mask in Interface Builder or programmatically. But I leave this to you.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cocoanotes.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cocoanotes.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cocoanotes.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cocoanotes.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cocoanotes.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cocoanotes.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cocoanotes.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cocoanotes.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cocoanotes.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cocoanotes.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cocoanotes.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cocoanotes.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cocoanotes.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cocoanotes.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cocoanotes.wordpress.com&amp;blog=5336888&amp;post=4&amp;subd=cocoanotes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cocoanotes.wordpress.com/2008/10/29/how-to-rotate-a-uitabbarcontroller/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8a4dd12089541b5475223d39448c3faa?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">geppyp</media:title>
		</media:content>
	</item>
	</channel>
</rss>
