<?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/"
	>

<channel>
	<title>Bubi Devs &#187; iPhone SDK</title>
	<atom:link href="http://www.bubidevs.net/category/sdk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bubidevs.net</link>
	<description>&#34;Siate affamati. Siate folli&#34;</description>
	<lastBuildDate>Sun, 15 Jan 2012 17:24:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>iTunes Connect Developer Guide si aggiorna alla versione 5.5</title>
		<link>http://www.bubidevs.net/2010/05/13/itunes-connect-developer-guide-si-aggiorna-alla-versione-5-5/</link>
		<comments>http://www.bubidevs.net/2010/05/13/itunes-connect-developer-guide-si-aggiorna-alla-versione-5-5/#comments</comments>
		<pubDate>Thu, 13 May 2010 21:44:48 +0000</pubDate>
		<dc:creator>Andrea Busi</dc:creator>
				<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[AppStore]]></category>
		<category><![CDATA[iTunes Connect]]></category>
		<category><![CDATA[iTunes Connect Developer Guide]]></category>

		<guid isPermaLink="false">http://www.bubidevs.net/?p=5562</guid>
		<description><![CDATA[Breve post per segnalarvi che Apple ha appena rilasciato la nuova versione dell&#8217;iTunes Connect Developer Guide, che si aggiorna così alla versione 5.5 Per chi non lo sapesse, questa è la guida ufficiale di Apple su come devono essere realizzare le applicazioni e cosa bisogna fare per inviarle per la vendita in AppStore. Ogni passo...]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://www.bubidevs.net/wp-content/uploads/2010/05/Schermata-2010-05-13-a-23.41.41.png"><img title="Schermata 2010-05-13 a 23.41.41" src="http://www.bubidevs.net/wp-content/uploads/2010/05/Schermata-2010-05-13-a-23.41.41.png" alt="" width="588" height="290" /></a></p>
<p>Breve post per segnalarvi che Apple ha appena rilasciato la nuova versione dell&#8217;<strong>iTunes Connect Developer Guide</strong>, che si aggiorna così alla versione 5.5</p>
<p>Per chi non lo sapesse, questa è la guida ufficiale di Apple su come devono essere realizzare le applicazioni e cosa bisogna fare per inviarle per la vendita in AppStore. Ogni passo ed ogni informazioni richiesta nell&#8217;iTunes Connect è spiegata in questa guida, assolutamente da leggere per tutti gli sviluppatori.</p>
<p><span id="more-5562"></span></p>
<p>I cambiamenti di questa versione sono i seguenti (in inglese):</p>
<ul>
<li>iPad screenshots, icon and delivery requirements as well as details on a new status called Missing Screenshot;</li>
<li>Details on how to enable your app for Game Center and set up your Leaderboard to test using iPhone SDK 4 beta;</li>
<li>Interval pricing details to help you learn how to schedule price tier changes in advance for your apps and in app purchases;</li>
<li>Information on the Over the Air download limit;</li>
<li>Recommended app name character count for optimal display on desktop and device App Stores.</li>
</ul>
<p>Potete scaricare l&#8217;iTunes Connect Develiper Guide a <a href="https://itunesconnect.apple.com/docs/iTunesConnect_DeveloperGuide.pdf">questo indirizzo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bubidevs.net/2010/05/13/itunes-connect-developer-guide-si-aggiorna-alla-versione-5-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XCode Tips&amp;Tricks #13 – Copiare del testo nella clipboard</title>
		<link>http://www.bubidevs.net/2010/04/28/xcode-tipstricks-13-%e2%80%93-copiare-del-testo-nella-clipboard/</link>
		<comments>http://www.bubidevs.net/2010/04/28/xcode-tipstricks-13-%e2%80%93-copiare-del-testo-nella-clipboard/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 05:00:11 +0000</pubDate>
		<dc:creator>Fast</dc:creator>
				<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[XCode Tips&Tricks]]></category>
		<category><![CDATA[appunti]]></category>
		<category><![CDATA[clipboard]]></category>
		<category><![CDATA[copia e incolla]]></category>
		<category><![CDATA[copiare]]></category>
		<category><![CDATA[generalPasteboard]]></category>
		<category><![CDATA[UIPasteboard]]></category>

		<guid isPermaLink="false">http://www.bubidevs.net/?p=5378</guid>
		<description><![CDATA[In questo nuovo appuntamento con i nostri &#8220;Tips&#38;Tricks&#8221; sulla programmazione per iPhone, vedremo come copiare del testo nella clipboard. Faremo in modo, infatti, che premendo un bottone venga copiato del testo, che sarà disponibile poi nella clipboard del nostro iPhone! Nel file &#8220;.h&#8221; vostra classe in cui volete implementare questa funzionalità dovrete dichiarare un componente...]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="aligncenter" src="http://www.bubidevs.net/Immagini/XCode-Tips&amp;Tricks.png" alt="" width="500" height="109" /></p>
<p style="text-align: left;">In questo nuovo appuntamento con i nostri &#8220;<a href="http://www.bubidevs.net/category/xcode-tipstricks/">Tips&amp;Tricks</a>&#8221; sulla programmazione per iPhone, vedremo come copiare del testo nella clipboard. Faremo in modo, infatti, che premendo un bottone venga copiato del testo, che sarà disponibile poi nella clipboard del nostro iPhone!</p>
<p style="text-align: left;"><span id="more-5378"></span></p>
<p>Nel file &#8220;.h&#8221; vostra classe in cui volete implementare questa funzionalità dovrete dichiarare un componente UIPasteboard. Eccovi un esempio qui di seguito:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@interface</span> provaClipboardViewController <span style="color: #002200;">:</span> UIViewController <span style="color: #002200;">&#123;</span>
	UIPasteboard <span style="color: #002200;">*</span>pasteboard;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span>IBAction<span style="color: #002200;">&#41;</span>copiaTesto;
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

<p>Alla riga 2 abbiamo definito una UIPasteboard, che ci permetterà di interagire con la clipboard dell&#8217;iPhone. Abbiamo, inoltre, definito un&#8217;azione &#8220;copiaTesto&#8221;, che abbiamo poi collegato ad un tasto definito in Interface Builder.</p>
<p>Nel file &#8220;.m&#8221; della classe dovremo poi definire il metodo &#8220;copiaTesto&#8221;. Le istruzioni che ci interessano sono alle righe 2 e 3:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span>IBAction<span style="color: #002200;">&#41;</span>copiaTesto<span style="color: #002200;">&#123;</span>
	pasteboard <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIPasteboard generalPasteboard<span style="color: #002200;">&#93;</span>;
	pasteboard.<span style="color: #a61390;">string</span> <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;XCode Tips&amp;amp;Tricks by BubiDevs&quot;</span>;
&nbsp;
	UIAlertView <span style="color: #002200;">*</span>alert<span style="color: #002200;">=</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIAlertView alloc<span style="color: #002200;">&#93;</span> initWithTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;BubiDevs!&quot;</span> message<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Testo copiato&quot;</span> delegate<span style="color: #002200;">:</span>self cancelButtonTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;OK&quot;</span> otherButtonTitles<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>alert show<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>alert release<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>Come vedete bastano due semplicissime istruzioni per copiare del testo nella clipboard.</p>
<p>Eccovi questo utilissimo tips in funzione:</p>
<p style="text-align: center;"><a href="http://www.bubidevs.net/wp-content/uploads/2010/04/screen11.png"><img class="alignnone size-thumbnail wp-image-5411" title="screen1" src="http://www.bubidevs.net/wp-content/uploads/2010/04/screen11-160x240.png" alt="" width="160" height="240" /></a> <a href="http://www.bubidevs.net/wp-content/uploads/2010/04/screen21.png"><img class="alignnone size-thumbnail wp-image-5412" title="screen2" src="http://www.bubidevs.net/wp-content/uploads/2010/04/screen21-160x240.png" alt="" width="160" height="240" /></a> <a href="http://www.bubidevs.net/wp-content/uploads/2010/04/screen3.png"><img class="alignnone size-thumbnail wp-image-5413" title="screen3" src="http://www.bubidevs.net/wp-content/uploads/2010/04/screen3-160x240.png" alt="" width="160" height="240" /></a></p>
<p>Spero vi sia piaciuto, se avete dei tips&amp;tricks da suggerirci contattateci tramite l&#8217;apposito form!</p>
<p style="text-align: right;">(<a href="http://stackoverflow.com/">fonte</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bubidevs.net/2010/04/28/xcode-tipstricks-13-%e2%80%93-copiare-del-testo-nella-clipboard/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>XCode Tips&amp;Tricks #12 &#8211; Come leggere un pdf in una UIWebView</title>
		<link>http://www.bubidevs.net/2010/04/23/xcode-tipstricks-12-come-leggere-un-pdf-in-una-uiwebview/</link>
		<comments>http://www.bubidevs.net/2010/04/23/xcode-tipstricks-12-come-leggere-un-pdf-in-una-uiwebview/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 08:00:13 +0000</pubDate>
		<dc:creator>Andrea Busi</dc:creator>
				<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[XCode Tips&Tricks]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[pdf reader]]></category>
		<category><![CDATA[scalePageToFit]]></category>
		<category><![CDATA[tips. tips&tricks]]></category>
		<category><![CDATA[UIWebView]]></category>

		<guid isPermaLink="false">http://www.bubidevs.net/?p=5049</guid>
		<description><![CDATA[Alcuni utenti di BubiDevs mi hanno chiesto come fare per leggere un documento pdf all&#8217;interno delle nostre applicazioni. Il procedimento è davvero molto semplice, basta partire da una comune UIWebView (potete utilizzare il nostro tutorial #8). Invece di caricare un indirizzo HTML utilizzate le seguenti istruzioni: 1 2 3 4 5 6 7 8 //...]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="alignnone" src="http://www.bubidevs.net/Immagini/XCode-Tips&amp;Tricks.png" alt="" width="500" height="109" /></p>
<p>Alcuni utenti di BubiDevs mi hanno chiesto come fare per leggere un documento pdf all&#8217;interno delle nostre applicazioni.</p>
<p>Il procedimento è davvero molto semplice, basta partire da una comune UIWebView (potete utilizzare il nostro <a href="http://www.bubidevs.net/2009/01/08/devtutorial-8-uiwebview-create-un-vostro-mini-browser/">tutorial #8</a>).</p>
<p><span id="more-5049"></span></p>
<p>Invece di caricare un indirizzo HTML utilizzate le seguenti istruzioni:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;">	<span style="color: #11740a; font-style: italic;">// carica il file pdf da locale</span>
	<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>indirizzo <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSBundle</span> mainBundle<span style="color: #002200;">&#93;</span> pathForResource<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;prev&quot;</span> ofType<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;pdf&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #400080;">NSURL</span> <span style="color: #002200;">*</span>url <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> fileURLWithPath<span style="color: #002200;">:</span>indirizzo<span style="color: #002200;">&#93;</span>;
	<span style="color: #400080;">NSURLRequest</span> <span style="color: #002200;">*</span>requestObj <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURLRequest</span> requestWithURL<span style="color: #002200;">:</span>url<span style="color: #002200;">&#93;</span>;
	<span style="color: #11740a; font-style: italic;">// visualizza la pagina nella UIWebView</span>
	<span style="color: #002200;">&#91;</span>webView loadRequest<span style="color: #002200;">:</span>requestObj<span style="color: #002200;">&#93;</span>;
	<span style="color: #11740a; font-style: italic;">// scala il contenuto della pagina a seconda delle dimensioni della UIWebView</span>
	webView.scalesPageToFit <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;</pre></td></tr></table></div>

<p>La prima istruzione ci permette di caricare un file pdf chiamato &#8220;prev&#8221;, che ovviamente deve essere inserito all&#8217;interno del nostro progetto. Le istruzioni 3, 4 e 6 non cambiano, sono uguali a quelle che già conoscete.</p>
<p>L&#8217;unica istruzione che merita un po&#8217; più di attenzione è l&#8217;ultima (riga 7). Essa ci permette di scalare il contenuto all&#8217;interno della nostraUIWebView, in modo che si adatti alla sua dimensione. Ecco come si presenta il nostro lettore di pdf:</p>
<p style="text-align: center;"><a href="http://www.bubidevs.net/wp-content/uploads/2010/03/Schermata-2010-03-26-a-15.43.35.png"><img class="alignnone size-full wp-image-5050" title="Schermata 2010-03-26 a 15.43.35" src="http://www.bubidevs.net/wp-content/uploads/2010/03/Schermata-2010-03-26-a-15.43.35.png" alt="" width="414" height="770" /></a></p>
<p>Ed ecco come invece sarebbe senza l&#8217;utilizzo dell&#8217;istruzione &#8220;scalePageToFit&#8221;, sicuramente molto meno &#8220;user-friendly&#8221;:</p>
<p style="text-align: center;"><a href="http://www.bubidevs.net/wp-content/uploads/2010/03/Schermata-2010-03-26-a-15.43.43.png"><img class="alignnone size-full wp-image-5051" title="Schermata 2010-03-26 a 15.43.43" src="http://www.bubidevs.net/wp-content/uploads/2010/03/Schermata-2010-03-26-a-15.43.43.png" alt="" width="414" height="770" /></a></p>
<p>Spero che questo tips vi sia stato utile, se volete segnalarmi dei vostri Tips&amp;Tricks ne sarei molto felice, li inserirei sicuramente in questa rubrica!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bubidevs.net/2010/04/23/xcode-tipstricks-12-come-leggere-un-pdf-in-una-uiwebview/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>XCode Tips&amp;Tricks #11 &#8211; Controllare l&#8217;inizio e la fine del caricamento di una UIWebView</title>
		<link>http://www.bubidevs.net/2010/04/20/xcode-tipstricks-11-controllare-linizio-e-la-fine-del-caricamento-di-una-uiwebview/</link>
		<comments>http://www.bubidevs.net/2010/04/20/xcode-tipstricks-11-controllare-linizio-e-la-fine-del-caricamento-di-una-uiwebview/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 08:00:02 +0000</pubDate>
		<dc:creator>Andrea Busi</dc:creator>
				<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[XCode Tips&Tricks]]></category>
		<category><![CDATA[caricamento]]></category>
		<category><![CDATA[NSMutableURLRequest]]></category>
		<category><![CDATA[UIWebView]]></category>
		<category><![CDATA[UIWebViewDelegate]]></category>
		<category><![CDATA[web view]]></category>
		<category><![CDATA[webViewDidFinishLoad]]></category>
		<category><![CDATA[webViewDidStartLoad]]></category>

		<guid isPermaLink="false">http://www.bubidevs.net/?p=5337</guid>
		<description><![CDATA[Oggi vi propongo un nuovo tips di XCode, che potrebbe non avere tantissima utilità (in alcuni casi), ma potrebbe aggiungere un &#8220;tocco di classe&#8221; alle vostre applicazioni. Vedremo, infatti, come capire quando una UIWebView inizia il caricamento  della pagina web (o meglio, quandi inizia una URLRequest) e quando la finisce. Per controllare questi due aspetti...]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="alignnone" src="http://www.bubidevs.net/Immagini/XCode-Tips&amp;Tricks.png" alt="" width="500" height="109" /></p>
<p>Oggi vi propongo un nuovo tips di XCode, che potrebbe non avere tantissima utilità (in alcuni casi), ma potrebbe aggiungere un &#8220;tocco di classe&#8221; alle vostre applicazioni.</p>
<p>Vedremo, infatti, come capire quando una UIWebView inizia il caricamento  della pagina web (o meglio, quandi inizia una URLRequest) e quando la finisce.</p>
<p><span id="more-5337"></span></p>
<p>Per controllare questi due aspetti non dovrete far altro che implementare nella vostra classe il protocollo &#8220;UIWebViewDelegate&#8221;:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@interface</span> SingoloFeedSafariViewController <span style="color: #002200;">:</span> UIViewController &lt;UIWebViewDelegate&gt; <span style="color: #002200;">&#123;</span></pre></div></div>

<p>e inserire, poi, questi due metodi nel file .m di implementazione della classe:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>webViewDidStartLoad<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIWebView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>view<span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span>spinner startAnimating<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>webViewDidFinishLoad<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIWebView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>view<span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span>spinner stopAnimating<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>Io ho semplicemente avviato e fermato una &#8220;UIActivityIndicatorView&#8221;, che mostrerà così all&#8217;utente il progresso del caricamento. Ecco due screen che vi mostrano questo semplice codice in funzione, nella prima immagine vedete la rotella attiva, mentre al file caricamento è ferma e non viene, ovviamente, visualizzata.</p>
<p style="text-align: center;"><a href="http://www.bubidevs.net/wp-content/uploads/2010/04/img.png"><img class="alignnone size-large wp-image-5339" title="img" src="http://www.bubidevs.net/wp-content/uploads/2010/04/img-500x461.png" alt="" width="500" height="461" /></a></p>
<p>Spero possa tornarvi utile, al prossimo appuntamento con &#8220;XCode Tips&amp;Tricks&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bubidevs.net/2010/04/20/xcode-tipstricks-11-controllare-linizio-e-la-fine-del-caricamento-di-una-uiwebview/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>XCode Tips&amp;Tricks #10 – Memoria disponibile scarsa: come rilevare tale avviso!</title>
		<link>http://www.bubidevs.net/2010/04/13/xcode-tipstricks-10-%e2%80%93-memoria-disponibile-scarsa-come-rilevare-tale-avviso/</link>
		<comments>http://www.bubidevs.net/2010/04/13/xcode-tipstricks-10-%e2%80%93-memoria-disponibile-scarsa-come-rilevare-tale-avviso/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 10:30:22 +0000</pubDate>
		<dc:creator>Fast</dc:creator>
				<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[XCode Tips&Tricks]]></category>
		<category><![CDATA[applicationDidReceiveMemoryWarning]]></category>
		<category><![CDATA[memoria]]></category>
		<category><![CDATA[RAM]]></category>
		<category><![CDATA[UIAlertView]]></category>
		<category><![CDATA[warning]]></category>

		<guid isPermaLink="false">http://www.bubidevs.net/?p=5248</guid>
		<description><![CDATA[Nell&#8217;appuntamento di oggi vedremo come rilevare quando la nostra applicazione va in &#8220;debito di memoria&#8221; (per rubare un&#8217;espressione agli atleti), ovvero quando la memoria RAM disponibile diventa poca e potrebbe compromettere il corretto funzionamento della nostra applicazione. Per rilevare tale mancanza ci basterà implementare il seguente metodo nel file &#8220;[nome-progetto]AppDelegate.m&#8221; del nostro progetto: - &#40;void&#41;applicationDidReceiveMemoryWarning:&#40;UIApplication...]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://www.bubidevs.net/Immagini/XCode-Tips&amp;Tricks.png"><img class="alignnone" src="http://www.bubidevs.net/Immagini/XCode-Tips&amp;Tricks.png" alt="" width="500" height="109" /></a></p>
<p style="text-align: left;">Nell&#8217;appuntamento di oggi vedremo come rilevare quando la nostra applicazione va in &#8220;debito di memoria&#8221; (per rubare un&#8217;espressione agli atleti), ovvero quando la memoria RAM disponibile diventa poca e potrebbe compromettere il corretto funzionamento della nostra applicazione.</p>
<p style="text-align: center;"><a href="http://www.bubidevs.net/wp-content/uploads/2010/04/IMG_0044.png"><img class="alignnone size-medium wp-image-5278" title="IMG_0044" src="http://www.bubidevs.net/wp-content/uploads/2010/04/IMG_0044-300x200.png" alt="" width="300" height="200" /></a></p>
<p style="text-align: left;"><span id="more-5248"></span></p>
<p style="text-align: left;">Per rilevare tale mancanza ci basterà implementare il seguente metodo nel file &#8220;[nome-progetto]AppDelegate.m&#8221; del nostro progetto:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>applicationDidReceiveMemoryWarning<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIApplication <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>application<span style="color: #002200;">&#123;</span>
	UIAlertView <span style="color: #002200;">*</span>avvisomem <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIAlertView alloc<span style="color: #002200;">&#93;</span> initWithTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Attenzione!&quot;</span> message<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Poca memoria disponibile!&quot;</span> delegate<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> cancelButtonTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;OK&quot;</span> otherButtonTitles<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>avvisomem show<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>avvisomem release<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p style="text-align: left;">Come potete vedere abbiamo semplicemente creato una UIAlertView che avviserà l&#8217;utente della scarsa memoria disponibile. Dopo aver avviato l&#8217;applicazione nel Simulatore, ci basterà andare nel menù &#8220;Hardware -&gt; Simula avviso memoria&#8221;</p>
<p style="text-align: center;"><a href="http://www.bubidevs.net/wp-content/uploads/2010/04/Schermata-2010-04-10-a-14.53.45.png"><img class="alignnone size-full wp-image-5253" title="Schermata 2010-04-10 a 14.53.45" src="http://www.bubidevs.net/wp-content/uploads/2010/04/Schermata-2010-04-10-a-14.53.45.png" alt="" width="354" height="268" /></a></p>
<p style="text-align: left;">ed ecco che comparirà il messaggio di avviso:</p>
<p style="text-align: center;"><a href="http://www.bubidevs.net/wp-content/uploads/2010/04/Schermata-2010-04-10-a-14.53.51.png"><img class="alignnone size-large wp-image-5254" title="Schermata 2010-04-10 a 14.53.51" src="http://www.bubidevs.net/wp-content/uploads/2010/04/Schermata-2010-04-10-a-14.53.51-376x700.png" alt="" width="376" height="700" /></a></p>
<p>Fateci sapere cosa ne pensate di questo tips&amp;tricks!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bubidevs.net/2010/04/13/xcode-tipstricks-10-%e2%80%93-memoria-disponibile-scarsa-come-rilevare-tale-avviso/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>XCode Tips&amp;Tricks #9 &#8211; Cambiare lo UserAgent delle UIWebView</title>
		<link>http://www.bubidevs.net/2010/04/09/xcode-tipstricks-9-cambiare-lo-useragent-delle-uiwebview/</link>
		<comments>http://www.bubidevs.net/2010/04/09/xcode-tipstricks-9-cambiare-lo-useragent-delle-uiwebview/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 21:55:24 +0000</pubDate>
		<dc:creator>Andrea Busi</dc:creator>
				<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[XCode Tips&Tricks]]></category>
		<category><![CDATA[NSURLRequest]]></category>
		<category><![CDATA[shouldStartLoadWithRequest]]></category>
		<category><![CDATA[tips&tricks]]></category>
		<category><![CDATA[UIWebView]]></category>
		<category><![CDATA[UIWebViewDelegate]]></category>
		<category><![CDATA[UserAgent]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://www.bubidevs.net/?p=5216</guid>
		<description><![CDATA[Rieccoci per un nuovo tips&#38;tricks dedicato alla programmazione per iPhone SDK. Oggi vedremo come cambiare l&#8217;user agent delle UIWebView. Lo UserAgent è, nella sua accezione più usata ma forse meno precisa, è un parametro che ci fornisce delle indicazioni su chi (o che cosa) si è connesso ad un server web. Per farvi un esempio, ogni...]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="alignnone" src="http://www.bubidevs.net/Immagini/XCode-Tips&amp;Tricks.png" alt="" width="500" height="109" /></p>
<p>Rieccoci per un nuovo tips&amp;tricks dedicato alla programmazione per iPhone SDK. Oggi vedremo come cambiare l&#8217;user agent delle UIWebView.</p>
<p>Lo UserAgent è, nella sua accezione più usata ma forse meno precisa, è un parametro che ci fornisce delle indicazioni su chi (o che cosa) si è connesso ad un server web. Per farvi un esempio, ogni browser ha il suo UserAgent, così come ogni applicazione che accede ad un server. Lo user agent permette di ricavare informazioni quali il browser utilizzato, il sistema operativo ed altro.</p>
<p>Questa informazione viene anche utilizzata quando utilizzate Safari Mobile per accedere ai vostri siti preferiti: sfruttando tale informazione, infatti, sarà possibile caricare una versione ottimizzata del sito web (come accada anche se aprite BubiDevs dal vostro iPhone).</p>
<p>Oggi vedremo come variare lo UserAgent dei componenti UIWebView, in modo che possiate avere un metodo per caricare pagine web personalizzate, magari con componenti visibili solo all&#8217;interno della vostra applicazione.</p>
<p><span id="more-5216"></span></p>
<p>Per prima cosa, inserite il delegato &#8220;UIWebViewDelegate&#8221; nella vostra classe. Eccovi un esempio:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@interface</span> ViewSafariController <span style="color: #002200;">:</span> UIViewController  &lt;UIWebViewDelegate&gt;<span style="color: #002200;">&#123;</span></pre></td></tr></table></div>

<p>Fatto ciò, dovrete implementare tale metodo:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">/* Modifica l'user agent del browser, in modo da caricare la pagina corretta */</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>webView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIWebView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>webView shouldStartLoadWithRequest<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSURLRequest</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>req navigationType<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIWebViewNavigationType<span style="color: #002200;">&#41;</span>navigationType <span style="color: #002200;">&#123;</span>
    <span style="color: #400080;">NSMutableURLRequest</span> <span style="color: #002200;">*</span>request <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSMutableURLRequest</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>req;
&nbsp;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>request respondsToSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>setValue<span style="color: #002200;">:</span>forHTTPHeaderField<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
        <span style="color: #002200;">&#91;</span>request setValue<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> stringWithFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;%@ AppNuova&quot;</span>, <span style="color: #002200;">&#91;</span>request valueForHTTPHeaderField<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;User-Agent&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span> forHTTPHeaderField<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;User_Agent&quot;</span><span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#125;</span>
    <span style="color: #a61390;">return</span> <span style="color: #a61390;">YES</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>È obbligatorio inserire il codice che vi ho appena riportato in questo metodo, altrimenti il vostro UserAgent non varierà e rimarrà sempre lo stesso (ve lo dico per esperienza personale xD).</p>
<p>La riga importante è la 6, in cui notate come abbiamo inserito &#8220;AppNuova&#8221; come UserAgent della nostra applicazione. Semplice vero?</p>
<p>Eccovi ora una prova di quello che abbiamo appena creato. Per un&#8217;applicazione che sto realizzando dovevo eliminare l&#8217;header del tema WPTouch (quello che utilizzo anche io nella versione mobile del blog), quindi ho inserito del codice php che mi controlla l&#8217;user agent del browser che carica la pagina: se esso corrisponde all&#8217;applicazione, non viene caricato l&#8217;header, altrimenti viene caricata normalmente l&#8217;intera pagina. Eccovi i due screen dimostrativi:</p>
<p style="text-align: center;">
<p style="text-align: center;">
<p style="text-align: center;"><a href="http://www.bubidevs.net/wp-content/uploads/2010/04/img2.png"><img class="alignnone size-large wp-image-5221" title="img2" src="http://www.bubidevs.net/wp-content/uploads/2010/04/img2-500x550.png" alt="" width="500" height="550" /></a></p>
<p style="text-align: center;"><a href="http://www.bubidevs.net/wp-content/uploads/2010/04/img1.png"><img class="alignnone size-large wp-image-5222" title="img1" src="http://www.bubidevs.net/wp-content/uploads/2010/04/img1-500x550.png" alt="" width="500" height="550" /></a></p>
<p>Spero che questo tips possa tornarvi utile, a me è servito per rendere l&#8217;aspetto grafico dell&#8217;applicazione più pulito e professionale!</p>
<p>Al prossimo &#8220;XCode Tips&amp;Tricks&#8221;!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bubidevs.net/2010/04/09/xcode-tipstricks-9-cambiare-lo-useragent-delle-uiwebview/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>iPhone SDK 3.2 Final rilasciato!</title>
		<link>http://www.bubidevs.net/2010/04/03/iphone-sdk-3-2-final-rilasciato/</link>
		<comments>http://www.bubidevs.net/2010/04/03/iphone-sdk-3-2-final-rilasciato/#comments</comments>
		<pubDate>Sat, 03 Apr 2010 13:55:14 +0000</pubDate>
		<dc:creator>Fast</dc:creator>
				<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[AppStore]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[Mac Os X]]></category>
		<category><![CDATA[programmazione]]></category>
		<category><![CDATA[Snow Leopard]]></category>

		<guid isPermaLink="false">http://www.bubidevs.net/?p=5146</guid>
		<description><![CDATA[Appena sono state aperte le porte dell&#8217;Apple Store di New York per la vendita del nuovo iPad, Apple ha rilasciato la versione finale dell&#8217;SDK, che giunge così alla versione 3.2 e supporta appieno la creazione di applicazioni per iPhone e iPad! Non vi sono particolari differenze tra questa versione e la GM (Gold Master) di...]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://www.bubidevs.net/wp-content/uploads/2010/04/Schermata-2010-04-03-a-15.49.32.png"><img class="alignnone size-large wp-image-5147" title="Schermata 2010-04-03 a 15.49.32" src="http://www.bubidevs.net/wp-content/uploads/2010/04/Schermata-2010-04-03-a-15.49.32-500x168.png" alt="" width="500" height="168" /></a></p>
<p style="text-align: left;">Appena sono state aperte le porte dell&#8217;Apple Store di New York per la vendita del nuovo iPad, Apple ha rilasciato la versione finale dell&#8217;SDK, che giunge così alla versione 3.2 e supporta appieno la creazione di applicazioni per iPhone e iPad!</p>
<p style="text-align: left;"><span id="more-5146"></span></p>
<p style="text-align: left;">Non vi sono particolari differenze tra questa versione e la GM (Gold Master) di qualche giorno fa, e non sono emerse novità di alcun genere.</p>
<p style="text-align: left;">Vi ricordo che per installare l&#8217;SDK 3.2 è necessario Mac OS X Snow Leopard, mentre potete scaricarlo da <a href="http://developer.apple.com/iphone/index.action#downloads">questo indirizzo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bubidevs.net/2010/04/03/iphone-sdk-3-2-final-rilasciato/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XCode Tips&amp;Trick #8 &#8211; UIAlertView con colore di sfondo personalizzato</title>
		<link>http://www.bubidevs.net/2010/03/29/xcode-tipstrick-8-uialertview-con-colore-di-sfondo-personalizzato/</link>
		<comments>http://www.bubidevs.net/2010/03/29/xcode-tipstrick-8-uialertview-con-colore-di-sfondo-personalizzato/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 10:15:28 +0000</pubDate>
		<dc:creator>Andrea Busi</dc:creator>
				<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[XCode Tips&Tricks]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[CustomAlert]]></category>
		<category><![CDATA[sfondo]]></category>
		<category><![CDATA[UIAlertView]]></category>
		<category><![CDATA[UIColor]]></category>

		<guid isPermaLink="false">http://www.bubidevs.net/?p=5066</guid>
		<description><![CDATA[Eccoci ancora una volta con un piccolo tip sulle UIAlertView. Questi sono sicuramente tra i componenti più utilizzati e anche più versatili, ma non è facile cambiarne l&#8217;aspetto grafico. Può capitare, infatti, che la classica UIAlertView &#8220;stoni&#8221; con il design della nostra applicazione, rendendo il tutto un po&#8217; meno piacevole. Personalizzarne il colore e lo...]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="alignnone" src="http://www.bubidevs.net/Immagini/XCode-Tips&amp;Tricks.png" alt="" width="500" height="109" /></p>
<p>Eccoci ancora una volta con un piccolo tip sulle UIAlertView. Questi sono sicuramente tra i componenti più utilizzati e anche più versatili, ma non è facile cambiarne l&#8217;aspetto grafico.</p>
<p>Può capitare, infatti, che la classica UIAlertView &#8220;stoni&#8221; con il design della nostra applicazione, rendendo il tutto un po&#8217; meno piacevole. Personalizzarne il colore e lo stile non è facile ed immediato, ma ho trovato su Internet una classe che permette di creare delle alert con colori personalizzati, semplificandoci davvero il lavoro!</p>
<p>Eccovi un esempio di ciò che tale classe permette di fare:</p>
<p style="text-align: center;"><a href="http://www.bubidevs.net/wp-content/uploads/2010/03/Schermata-2010-03-28-a-23.55.25.png"><img class="alignnone size-full wp-image-5067" title="Schermata 2010-03-28 a 23.55.25" src="http://www.bubidevs.net/wp-content/uploads/2010/03/Schermata-2010-03-28-a-23.55.25.png" alt="" width="308" height="188" /></a></p>
<p style="text-align: center;">
<p><span id="more-5066"></span></p>
<p>Per implementare questo componente create una nuova classe di nome &#8220;CustomAlert&#8221; e inserite nel file .h questo codice:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &lt;UIKit/UIKit.h&gt;</span>
&nbsp;
<span style="color: #a61390;">@interface</span> CustomAlert <span style="color: #002200;">:</span> UIAlertView<span style="color: #002200;">&#123;</span>
&nbsp;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setBackgroundColor<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIColor <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>background withStrokeColor<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIColor <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> stroke;
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

<p>e nel file .m questo codice:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &quot;CustomAlert.h&quot;</span>
&nbsp;
<span style="color: #a61390;">@interface</span> CustomAlert <span style="color: #002200;">&#40;</span>Private<span style="color: #002200;">&#41;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> drawRoundedRect<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGRect<span style="color: #002200;">&#41;</span> rect inContext<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGContextRef<span style="color: #002200;">&#41;</span>
context withRadius<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGFloat<span style="color: #002200;">&#41;</span> radius;
&nbsp;
<span style="color: #a61390;">@end</span>
&nbsp;
<span style="color: #a61390;">static</span> UIColor <span style="color: #002200;">*</span>fillColor <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
<span style="color: #a61390;">static</span> UIColor <span style="color: #002200;">*</span>borderColor <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
&nbsp;
<span style="color: #a61390;">@implementation</span> CustomAlert
&nbsp;
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> setBackgroundColor<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIColor <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> background
			withStrokeColor<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIColor <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> stroke
<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>fillColor <span style="color: #002200;">!=</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		<span style="color: #002200;">&#91;</span>fillColor release<span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#91;</span>borderColor release<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	fillColor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>background retain<span style="color: #002200;">&#93;</span>;
	borderColor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>stroke retain<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>initWithFrame<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGRect<span style="color: #002200;">&#41;</span>frame
<span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>self <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>super initWithFrame<span style="color: #002200;">:</span>frame<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
        <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>fillColor <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span>
		<span style="color: #002200;">&#123;</span>
			fillColor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIColor blackColor<span style="color: #002200;">&#93;</span> retain<span style="color: #002200;">&#93;</span>;
			borderColor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIColor colorWithHue<span style="color: #002200;">:</span><span style="color: #2400d9;">0.625</span>
									  saturation<span style="color: #002200;">:</span><span style="color: #2400d9;">0.0</span> brightness<span style="color: #002200;">:</span><span style="color: #2400d9;">0.8</span> alpha<span style="color: #002200;">:</span><span style="color: #2400d9;">0.8</span><span style="color: #002200;">&#93;</span>
						   retain<span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#125;</span>
    <span style="color: #002200;">&#125;</span>
&nbsp;
    <span style="color: #a61390;">return</span> self;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>layoutSubviews
<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span>UIView <span style="color: #002200;">*</span>sub <span style="color: #a61390;">in</span> <span style="color: #002200;">&#91;</span>self subviews<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>sub class<span style="color: #002200;">&#93;</span> <span style="color: #002200;">==</span> <span style="color: #002200;">&#91;</span>UIImageView class<span style="color: #002200;">&#93;</span> <span style="color: #002200;">&amp;</span>amp;<span style="color: #002200;">&amp;</span>amp; sub.tag <span style="color: #002200;">==</span> <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>
		<span style="color: #002200;">&#123;</span>
			<span style="color: #11740a; font-style: italic;">// The alert background UIImageView tag is 0,</span>
			<span style="color: #11740a; font-style: italic;">// if you are adding your own UIImageView's</span>
			<span style="color: #11740a; font-style: italic;">// make sure your tags != 0 or this fix</span>
			<span style="color: #11740a; font-style: italic;">// will remove your UIImageView's as well!</span>
			<span style="color: #002200;">&#91;</span>sub removeFromSuperview<span style="color: #002200;">&#93;</span>;
			<span style="color: #a61390;">break</span>;
		<span style="color: #002200;">&#125;</span>
	<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>drawRect<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGRect<span style="color: #002200;">&#41;</span>rect
<span style="color: #002200;">&#123;</span>
	CGContextRef context <span style="color: #002200;">=</span> UIGraphicsGetCurrentContext<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	CGContextClearRect<span style="color: #002200;">&#40;</span>context, rect<span style="color: #002200;">&#41;</span>;
	CGContextSetAllowsAntialiasing<span style="color: #002200;">&#40;</span>context, <span style="color: #a61390;">true</span><span style="color: #002200;">&#41;</span>;
	CGContextSetLineWidth<span style="color: #002200;">&#40;</span>context, <span style="color: #2400d9;">0.0</span><span style="color: #002200;">&#41;</span>;
	CGContextSetAlpha<span style="color: #002200;">&#40;</span>context, <span style="color: #2400d9;">0.8</span><span style="color: #002200;">&#41;</span>;
	CGContextSetLineWidth<span style="color: #002200;">&#40;</span>context, <span style="color: #2400d9;">2.0</span><span style="color: #002200;">&#41;</span>;
	CGContextSetStrokeColorWithColor<span style="color: #002200;">&#40;</span>context, <span style="color: #002200;">&#91;</span>borderColor CGColor<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;
	CGContextSetFillColorWithColor<span style="color: #002200;">&#40;</span>context, <span style="color: #002200;">&#91;</span>fillColor CGColor<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// Draw background</span>
	CGFloat backOffset <span style="color: #002200;">=</span> <span style="color: #2400d9;">2</span>;
	CGRect backRect <span style="color: #002200;">=</span> CGRectMake<span style="color: #002200;">&#40;</span>rect.origin.x <span style="color: #002200;">+</span> backOffset,
								 rect.origin.y <span style="color: #002200;">+</span> backOffset,
								 rect.size.width <span style="color: #002200;">-</span> backOffset<span style="color: #002200;">*</span><span style="color: #2400d9;">2</span>,
								 rect.size.height <span style="color: #002200;">-</span> backOffset<span style="color: #002200;">*</span><span style="color: #2400d9;">2</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>self drawRoundedRect<span style="color: #002200;">:</span>backRect inContext<span style="color: #002200;">:</span>context withRadius<span style="color: #002200;">:</span><span style="color: #2400d9;">8</span><span style="color: #002200;">&#93;</span>;
	CGContextDrawPath<span style="color: #002200;">&#40;</span>context, kCGPathFillStroke<span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// Clip Context</span>
	CGRect clipRect <span style="color: #002200;">=</span> CGRectMake<span style="color: #002200;">&#40;</span>backRect.origin.x <span style="color: #002200;">+</span> backOffset<span style="color: #002200;">-</span><span style="color: #2400d9;">1</span>,
								 backRect.origin.y <span style="color: #002200;">+</span> backOffset<span style="color: #002200;">-</span><span style="color: #2400d9;">1</span>,
								 backRect.size.width <span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>backOffset<span style="color: #002200;">-</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">*</span><span style="color: #2400d9;">2</span>,
								 backRect.size.height <span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>backOffset<span style="color: #002200;">-</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">*</span><span style="color: #2400d9;">2</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>self drawRoundedRect<span style="color: #002200;">:</span>clipRect inContext<span style="color: #002200;">:</span>context withRadius<span style="color: #002200;">:</span><span style="color: #2400d9;">8</span><span style="color: #002200;">&#93;</span>;
	CGContextClip <span style="color: #002200;">&#40;</span>context<span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">//Draw highlight</span>
	CGGradientRef glossGradient;
	CGColorSpaceRef rgbColorspace;
	<span style="color: #a61390;">size_t</span> num_locations <span style="color: #002200;">=</span> <span style="color: #2400d9;">2</span>;
	CGFloat locations<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">2</span><span style="color: #002200;">&#93;</span> <span style="color: #002200;">=</span> <span style="color: #002200;">&#123;</span> <span style="color: #2400d9;">0.0</span>, <span style="color: #2400d9;">1.0</span> <span style="color: #002200;">&#125;</span>;
	CGFloat components<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">8</span><span style="color: #002200;">&#93;</span> <span style="color: #002200;">=</span> <span style="color: #002200;">&#123;</span> <span style="color: #2400d9;">1.0</span>, <span style="color: #2400d9;">1.0</span>, <span style="color: #2400d9;">1.0</span>, <span style="color: #2400d9;">0.35</span>, <span style="color: #2400d9;">1.0</span>, <span style="color: #2400d9;">1.0</span>, <span style="color: #2400d9;">1.0</span>, <span style="color: #2400d9;">0.06</span> <span style="color: #002200;">&#125;</span>;
	rgbColorspace <span style="color: #002200;">=</span> CGColorSpaceCreateDeviceRGB<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
	glossGradient <span style="color: #002200;">=</span> CGGradientCreateWithColorComponents<span style="color: #002200;">&#40;</span>rgbColorspace,
														components, locations, num_locations<span style="color: #002200;">&#41;</span>;
&nbsp;
	CGRect ovalRect <span style="color: #002200;">=</span> CGRectMake<span style="color: #002200;">&#40;</span><span style="color: #002200;">-</span><span style="color: #2400d9;">130</span>, <span style="color: #002200;">-</span><span style="color: #2400d9;">115</span>, <span style="color: #002200;">&#40;</span>rect.size.width<span style="color: #002200;">*</span><span style="color: #2400d9;">2</span><span style="color: #002200;">&#41;</span>,
								 rect.size.width<span style="color: #002200;">/</span><span style="color: #2400d9;">2</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	CGPoint start <span style="color: #002200;">=</span> CGPointMake<span style="color: #002200;">&#40;</span>rect.origin.x, rect.origin.y<span style="color: #002200;">&#41;</span>;
	CGPoint end <span style="color: #002200;">=</span> CGPointMake<span style="color: #002200;">&#40;</span>rect.origin.x, rect.size.height<span style="color: #002200;">/</span><span style="color: #2400d9;">5</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	CGContextSetAlpha<span style="color: #002200;">&#40;</span>context, <span style="color: #2400d9;">1.0</span><span style="color: #002200;">&#41;</span>;
	CGContextAddEllipseInRect<span style="color: #002200;">&#40;</span>context, ovalRect<span style="color: #002200;">&#41;</span>;
	CGContextClip <span style="color: #002200;">&#40;</span>context<span style="color: #002200;">&#41;</span>;
&nbsp;
	CGContextDrawLinearGradient<span style="color: #002200;">&#40;</span>context, glossGradient, start, end, <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	CGGradientRelease<span style="color: #002200;">&#40;</span>glossGradient<span style="color: #002200;">&#41;</span>;
	CGColorSpaceRelease<span style="color: #002200;">&#40;</span>rgbColorspace<span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> drawRoundedRect<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGRect<span style="color: #002200;">&#41;</span> rrect inContext<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGContextRef<span style="color: #002200;">&#41;</span> context
			  withRadius<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGFloat<span style="color: #002200;">&#41;</span> radius
<span style="color: #002200;">&#123;</span>
	CGContextBeginPath <span style="color: #002200;">&#40;</span>context<span style="color: #002200;">&#41;</span>;
&nbsp;
	CGFloat minx <span style="color: #002200;">=</span> CGRectGetMinX<span style="color: #002200;">&#40;</span>rrect<span style="color: #002200;">&#41;</span>, midx <span style="color: #002200;">=</span> CGRectGetMidX<span style="color: #002200;">&#40;</span>rrect<span style="color: #002200;">&#41;</span>,
	maxx <span style="color: #002200;">=</span> CGRectGetMaxX<span style="color: #002200;">&#40;</span>rrect<span style="color: #002200;">&#41;</span>;
&nbsp;
	CGFloat miny <span style="color: #002200;">=</span> CGRectGetMinY<span style="color: #002200;">&#40;</span>rrect<span style="color: #002200;">&#41;</span>, midy <span style="color: #002200;">=</span> CGRectGetMidY<span style="color: #002200;">&#40;</span>rrect<span style="color: #002200;">&#41;</span>,
	maxy <span style="color: #002200;">=</span> CGRectGetMaxY<span style="color: #002200;">&#40;</span>rrect<span style="color: #002200;">&#41;</span>;
&nbsp;
	CGContextMoveToPoint<span style="color: #002200;">&#40;</span>context, minx, midy<span style="color: #002200;">&#41;</span>;
	CGContextAddArcToPoint<span style="color: #002200;">&#40;</span>context, minx, miny, midx, miny, radius<span style="color: #002200;">&#41;</span>;
	CGContextAddArcToPoint<span style="color: #002200;">&#40;</span>context, maxx, miny, maxx, midy, radius<span style="color: #002200;">&#41;</span>;
	CGContextAddArcToPoint<span style="color: #002200;">&#40;</span>context, maxx, maxy, midx, maxy, radius<span style="color: #002200;">&#41;</span>;
	CGContextAddArcToPoint<span style="color: #002200;">&#40;</span>context, minx, maxy, minx, midy, radius<span style="color: #002200;">&#41;</span>;
	CGContextClosePath<span style="color: #002200;">&#40;</span>context<span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>dealloc
<span style="color: #002200;">&#123;</span>
    <span style="color: #002200;">&#91;</span>super dealloc<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

<p>Per utilizzare delle UIAlertView personalizzate dovrete utilizzare questa classe nello stesso modo in cui utilizzare gli alert tradizionali, eccovi un esempio:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">	<span style="color: #11740a; font-style: italic;">// Imposto i colori</span>
	<span style="color: #002200;">&#91;</span>CustomAlert setBackgroundColor<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIColor blueColor<span style="color: #002200;">&#93;</span> withStrokeColor<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIColor cyanColor<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #11740a; font-style: italic;">// Creo e visualizzo l'alert personalizzata</span>
	CustomAlert <span style="color: #002200;">*</span>alert<span style="color: #002200;">=</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>CustomAlert alloc<span style="color: #002200;">&#93;</span> initWithTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Prova!&quot;</span> message<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Eccovi un'alert personalizzata..&quot;</span> delegate<span style="color: #002200;">:</span>self cancelButtonTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;OK&quot;</span> otherButtonTitles<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>alert show<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>alert release<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>Questo è l&#8217;unico modo che ho trovato per personalizzare il colore di una UIAlertView, e devo dire che i risultati non sono male. Se siete a conoscenza di altri metodi fatemelo sapere nei commenti!</p>
<p><strong><span style="color: #ff0000;">Aggiornamento 21/01/2011:</span></strong> il codice è stato aggiornato (come nella versione originale) per funzionare anche con iOS 4.2 <img src='http://www.bubidevs.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p style="text-align: right;"><em>I meriti di tale classe sono di kwigbo, trovate l&#8217;articolo originale a </em><a href="http://kwigbo.com/post/318396305/iphone-sdk-custom-uialertview-background-color"><em>questo indirizzo</em></a><em>.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bubidevs.net/2010/03/29/xcode-tipstrick-8-uialertview-con-colore-di-sfondo-personalizzato/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>DevTutorial #27 &#8211; Incremento automatico del numero di build e data in un progetto</title>
		<link>http://www.bubidevs.net/2010/03/23/devtutorial-27-incremento-automatico-del-numero-di-build-e-data-in-un-progetto/</link>
		<comments>http://www.bubidevs.net/2010/03/23/devtutorial-27-incremento-automatico-del-numero-di-build-e-data-in-un-progetto/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 08:00:10 +0000</pubDate>
		<dc:creator>Andrea Busi</dc:creator>
				<category><![CDATA[DevTutorial]]></category>
		<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[Bundle version]]></category>
		<category><![CDATA[CFBuildDate]]></category>
		<category><![CDATA[CFBuildNumber]]></category>
		<category><![CDATA[numero versione]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://www.bubidevs.net/?p=4793</guid>
		<description><![CDATA[In questo nuovo tutorial vedremo come realizzare una cosa molto particolare, che potrà tornare utile soprattutto quando distrubuirete l&#8217;applicazione a diversi beta tester. Vedremo, infatti, come inserire all&#8217;interno del nostro progetto (oltre al classico numero di versione dell&#8217;applicazione) un numero di build progressimo, insieme anche alla data della build in questione. Utilizzeremo uno script automatico,...]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="alignnone" src="http://www.bubidevs.net/Immagini/Logo-DevTutorial.png" alt="" width="490" height="200" /></p>
<p>In questo nuovo tutorial vedremo come realizzare una cosa molto particolare, che potrà tornare utile soprattutto quando distrubuirete l&#8217;applicazione a diversi beta tester.</p>
<p>Vedremo, infatti, come inserire all&#8217;interno del nostro progetto (oltre al classico numero di versione dell&#8217;applicazione) un numero di build progressimo, insieme anche alla data della build in questione.</p>
<p>Utilizzeremo uno script automatico, che ad ogni build creata aumenterà il numero di build e aggiornerà la data della build Potremo, così, avere sempre sotto controllo l&#8217;esatta versione della nostra applicazione, in modo da avere un controllo completo su tutte le versioni.</p>
<p>Buon tutorial!</p>
<p><span id="more-4793"></span></p>
<h1>1. Inseriamo lo script</h1>
<p>Entriamo nel progetto in cui vogliamo inserire l&#8217;incremento automatico del numero di versione. Facciamo clic con il tasto destro sul nome del nostro progetto e scegliamo &#8220;Add -&gt; New Build Phase -&gt; New Run Script Build Phase&#8221;.</p>
<p style="text-align: center;"><a href="http://www.bubidevs.net/wp-content/uploads/2010/03/Schermata-2010-03-15-a-21.20.14.png"><img class="alignnone size-large wp-image-4796" title="Schermata 2010-03-15 a 21.20.14" src="http://www.bubidevs.net/wp-content/uploads/2010/03/Schermata-2010-03-15-a-21.20.14-499x119.png" alt="" width="499" height="119" /></a></p>
<p>Si aprirà una schermata come questa:</p>
<p style="text-align: center;"><a href="http://www.bubidevs.net/wp-content/uploads/2010/03/Schermata-2010-03-15-a-21.22.45.png"><img class="alignnone size-large wp-image-4795" title="Schermata 2010-03-15 a 21.22.45" src="http://www.bubidevs.net/wp-content/uploads/2010/03/Schermata-2010-03-15-a-21.22.45-500x530.png" alt="" width="500" height="530" /></a></p>
<p>in cui dovremo andare ad inserire lo script necessario. Eccovelo:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># Auto Increment Version Script</span>
<span style="color: #007800;">buildPlist</span>=<span style="color: #ff0000;">&quot;prova-Info.plist&quot;</span>
<span style="color: #007800;">CFBuildNumber</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>PlistBuddy <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;Print CFBuildNumber&quot;</span> <span style="color: #007800;">$buildPlist</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">CFBuildNumber</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$CFBuildNumber</span> + <span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>div <span style="color: #007800;">id</span>=<span style="color: #ff0000;">&quot;_mcePaste&quot;</span><span style="color: #000000; font-weight: bold;">&gt;/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>PlistBuddy <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;Set :CFBuildNumber <span style="color: #007800;">$CFBuildNumber</span>&quot;</span> <span style="color: #007800;">$buildPlist</span>
<span style="color: #007800;">CFBuildDate</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>PlistBuddy <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;Set :CFBuildDate <span style="color: #007800;">$CFBuildDate</span>&quot;</span> <span style="color: #007800;">$buildPlist</span><span style="color: #000000; font-weight: bold;">&lt;/</span>div<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>Ovviamente dovete modificare la stringa <em>buildPlist=&#8221;prova-Info.plis&#8221;</em>, inserendo il nome del vostro file &#8220;.plist&#8221; (che sarà nella forma &#8220;nome_progetto-Info.plist&#8221;).</p>
<p style="text-align: center;"><a href="http://www.bubidevs.net/wp-content/uploads/2010/03/Schermata-2010-03-15-a-21.23.21.png"><img class="alignnone size-large wp-image-4797" title="Schermata 2010-03-15 a 21.23.21" src="http://www.bubidevs.net/wp-content/uploads/2010/03/Schermata-2010-03-15-a-21.23.21-500x530.png" alt="" width="500" height="530" /></a></p>
<p>Chiudete pure tale finestra.</p>
<h1>2. Inseriamo le variabili necessarie</h1>
<p>Spostatevi, ora, nella cartella &#8220;Resources&#8221; ed aprite il file &#8220;xxx-Info.plist&#8221; che trovate al suo interno (dove xxx è il nome del vostro progetto).</p>
<p>Utilizzando il &#8220;+&#8221; che appare di fianco alle voci già presenti, inserite due nuovi valori, rispettivamente chiamati &#8220;<em>CFBuildDate</em>&#8221; e &#8220;<em>CFBuildNumber</em>&#8220;. Non c&#8217;è bisogno che inseriate dei valori per queste due voci, in quanto verranno create automaticamente dallo script. Ecco come deve essere il vostro file &#8220;.plist&#8221;:</p>
<p style="text-align: center;"><a href="http://www.bubidevs.net/wp-content/uploads/2010/03/Schermata-2010-03-15-a-21.26.45.png"><img class="alignnone size-large wp-image-4798" title="Schermata 2010-03-15 a 21.26.45" src="http://www.bubidevs.net/wp-content/uploads/2010/03/Schermata-2010-03-15-a-21.26.45-500x327.png" alt="" width="500" height="327" /></a></p>
<p>Potete notare che è già presente la stringa &#8220;<em>Bundle version</em>&#8220;, che identifica la versione della nostra applicazione. Sarà anche questo un valore che andremo a leggere. Salvate il file e chiudetelo pure.</p>
<h1>3. Inseriamo il codice necessario</h1>
<p>Non ci resta che inserire quelle poche istruzioni che ci permetteranno di leggere il numero di versione, il numero di build e la data dell&#8217;ultima build. Inserite, dove vi serve, il seguente codice:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>versione <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSBundle</span> mainBundle<span style="color: #002200;">&#93;</span> infoDictionary<span style="color: #002200;">&#93;</span> objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;CFBundleVersion&quot;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>build <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSBundle</span> mainBundle<span style="color: #002200;">&#93;</span> infoDictionary<span style="color: #002200;">&#93;</span> objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;CFBuildNumber&quot;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>data <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSBundle</span> mainBundle<span style="color: #002200;">&#93;</span> infoDictionary<span style="color: #002200;">&#93;</span> objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;CFBuildDate&quot;</span><span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

<p>Come vedete abbiamo ottenuto tre stringhe con i rispettivi tre valori, che potrete utilizzare a vostro piacimento!</p>
<p style="text-align: center;"><a href="http://www.bubidevs.net/wp-content/uploads/2010/03/Schermata-2010-03-15-a-22.01.16.png"><img class="alignnone size-full wp-image-4802" title="Schermata 2010-03-15 a 22.01.16" src="http://www.bubidevs.net/wp-content/uploads/2010/03/Schermata-2010-03-15-a-22.01.16.png" alt="" width="414" height="770" /></a></p>
<p style="text-align: center;"><a href="http://www.bubidevs.net/wp-content/uploads/2010/03/AutoBuildExample.zip"><img src="http://www.bubidevs.net/Immagini/download_icon.png" alt="" width="33" height="40" align="middle" /></a> Se Avete Problemi, questo è il <a href="http://www.bubidevs.net/wp-content/uploads/2010/03/AutoBuildExample.zip">nostro file di progetto</a>.</p>
<p style="text-align: left;"><strong><span style="color: #ff0000;">Nota:</span></strong> per visualizzare lo script inserito espandete l&#8217;elemento &#8220;<em>Targets</em>&#8221; del progetto e fate doppio clic su &#8220;<em>Run Script</em>&#8220;.</p>
<p style="text-align: center;"><a href="http://www.bubidevs.net/wp-content/uploads/2010/03/Schermata-2010-03-15-a-22.11.08.png"><img class="alignnone size-full wp-image-4804" title="Schermata 2010-03-15 a 22.11.08" src="http://www.bubidevs.net/wp-content/uploads/2010/03/Schermata-2010-03-15-a-22.11.08.png" alt="" width="226" height="106" /></a></p>
<p style="text-align: left;"><em>La guida è stata creata da Andrea Busi per “<a style="color: #3362fb; text-decoration: none;" href="http://www.bubidevs.net/2010/03/13/2010/02/09/2009/09/25/2009/08/08/2009/07/04/">Bubi Devs</a>”, prendendo spunto da questa guida: &#8220;<a href="http://imthi.com/blog/programming/auto-increment-build-number-date-in-xcode-iphone-project.php">Auto Increment Build Number &amp; Date in XCode iPhone Project</a>&#8220;. I meriti, quindi, sono del legittimo autore.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bubidevs.net/2010/03/23/devtutorial-27-incremento-automatico-del-numero-di-build-e-data-in-un-progetto/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>XCode Tips&amp;Tricks #7 &#8211; Inserire una UITextFiel in una UIViewAlert</title>
		<link>http://www.bubidevs.net/2010/03/16/la-posta-di-bubidevs-7-inserire-una-uitextfiel-in-una-uiviewalert/</link>
		<comments>http://www.bubidevs.net/2010/03/16/la-posta-di-bubidevs-7-inserire-una-uitextfiel-in-una-uiviewalert/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 10:00:07 +0000</pubDate>
		<dc:creator>Andrea Busi</dc:creator>
				<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[XCode Tips&Tricks]]></category>
		<category><![CDATA[posta di BubiDevs]]></category>
		<category><![CDATA[text field]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tips&tricks]]></category>
		<category><![CDATA[UIAlertView]]></category>
		<category><![CDATA[UITextField]]></category>

		<guid isPermaLink="false">http://www.bubidevs.net/?p=4741</guid>
		<description><![CDATA[Solo qualche giorno fa vi avevamo spiegato come inserire più bottoni in una UIAlertView. Subito dopo ho ricevuto via Twitter una richiesta da &#8220;Luigix95&#8220;, che mi chiedeva come inserire una UITextField all&#8217;interno di un UIViewAlert, in modo da permettere all&#8217;utente di inserire del testo (in pratica un comportamente simile a quello che avviene quando scaricate...]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;">
<p style="text-align: center;"><img class="alignnone" src="http://www.bubidevs.net/Immagini/XCode-Tips&amp;Tricks.png" alt="" width="500" height="109" /></p>
<p>Solo qualche giorno fa vi <a href="http://www.bubidevs.net/2010/03/10/la-posta-di-bubidevs-6-come-inserire-piu-bottoni-in-una-uialertview/">avevamo spiegato</a> come inserire più bottoni in una UIAlertView.</p>
<p>Subito dopo ho ricevuto via Twitter una richiesta da &#8220;<em>Luigix95</em>&#8220;, che mi chiedeva come inserire una UITextField all&#8217;interno di un UIViewAlert, in modo da permettere all&#8217;utente di inserire del testo (in pratica un comportamente simile a quello che avviene quando scaricate un&#8217;applicazione e AppStore vi richiede la password).</p>
<p>Ecco, quindi, il procedimento da seguire.</p>
<p><span id="more-4741"></span>Nel file &#8220;.h&#8221; della vostra classe inserite la dichiarazione di una UITextField, eccovi un esempio:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@interface</span> provaAlertViewController <span style="color: #002200;">:</span> UIViewController <span style="color: #002200;">&amp;</span>lt;UIAlertViewDelegate, UITextFieldDelegate<span style="color: #002200;">&amp;</span>gt; <span style="color: #002200;">&#123;</span>
  UITextField <span style="color: #002200;">*</span>textField;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@end</span></pre></td></tr></table></div>

<p>Come vedete abbiamo definito una text field (riga 2). Ricordatevi, inoltre, di inserire i due delegati &#8220;UIAlertViewDelegate&#8221; e &#8220;UItextFieldDelegate&#8221;, che ci permetteranno di interagire con la UIAlertView e con la UITextField.</p>
<p>Nel file &#8220;.m&#8221; definiamo (dove vi serve) una UIAlertView, e inseriamo anche la text field appena definita:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"> UIAlertView <span style="color: #002200;">*</span>alertView <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIAlertView alloc<span style="color: #002200;">&#93;</span> initWithTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Inserisci il tuo nome&quot;</span> message<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot; &quot;</span> delegate<span style="color: #002200;">:</span>self cancelButtonTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Annulla&quot;</span> otherButtonTitles<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;OK&quot;</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
 <span style="color: #11740a; font-style: italic;">// definiamo e inseriamo la TextField</span>
 textField <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UITextField alloc<span style="color: #002200;">&#93;</span> initWithFrame<span style="color: #002200;">:</span>CGRectMake<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">20.0</span>, <span style="color: #2400d9;">45.0</span>, <span style="color: #2400d9;">245.0</span>, <span style="color: #2400d9;">25.0</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
 textField.delegate <span style="color: #002200;">=</span> self;
 <span style="color: #002200;">&#91;</span>textField setBackgroundColor<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIColor whiteColor<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
 <span style="color: #002200;">&#91;</span>alertView addSubview<span style="color: #002200;">:</span>textField<span style="color: #002200;">&#93;</span>;
 <span style="color: #11740a; font-style: italic;">// lo spostiamo un po' in alto, altrimenti viene nascosto dalla tastiera</span>
 CGAffineTransform alza <span style="color: #002200;">=</span> CGAffineTransformMakeTranslation<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0.0</span>, <span style="color: #2400d9;">100.0</span><span style="color: #002200;">&#41;</span>;
 <span style="color: #002200;">&#91;</span>alertView setTransform<span style="color: #002200;">:</span>alza<span style="color: #002200;">&#93;</span>;
 <span style="color: #11740a; font-style: italic;">// mostriamo l'alert view</span>
 <span style="color: #002200;">&#91;</span>alertView show<span style="color: #002200;">&#93;</span>;
 <span style="color: #002200;">&#91;</span>alertView release<span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

<p>Come potete vedere, alla riga 3 abbiamo istanziato una UITextField con delle dimensioni che possano stare nell&#8217;UIAlertView. Settiamo, poi, il delegato (riga 4, che vedremo fra poco a cosa servirà), il colore (riga 5) e la inseriamo poi nell&#8217;alert (riga 6).</p>
<p>Alla riga 8 definiamo una trasformazione, che sposterà verso l&#8217;alto la nostra UIAlertView, in modo che essa non venga coperta dalla tastiera che apparirà per scrivere nella text field.</p>
<p>Ci mancano solo due semplici metodi da inserire, due metodi appartenenti ai delegati che abbiamo definito nell&#8217;intestazione della classe. Eccoli:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>alertView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIAlertView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>actionSheet clickedButtonAtIndex<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>buttonIndex <span style="color: #002200;">&#123;</span>
 <span style="color: #11740a; font-style: italic;">// l'utente ha selezionato si, quindi vuole azzerare i punteggi</span>
 <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>buttonIndex <span style="color: #002200;">==</span> <span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
 <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>textValue <span style="color: #002200;">=</span> textField.text;
 NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;testo: %@&quot;</span>,textValue<span style="color: #002200;">&#41;</span>;
 <span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>textFieldShouldReturn<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITextField <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>textField<span style="color: #002200;">&#123;</span>
 <span style="color: #002200;">&#91;</span>textField resignFirstResponder<span style="color: #002200;">&#93;</span>;
 <span style="color: #a61390;">return</span> <span style="color: #a61390;">YES</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>Il primo metodo ci permette di capire il bottone che è stato premuto (nel nostro caso controlliamo che sia stato premuto &#8220;Ok&#8221;), e ricaviamo il testo inserito, stampandolo semplicemente nella console di debug.</p>
<p>Il secondo metodo, invece, lo avrete già visto più volte, e permette alla tastiera di chiudersi quando si clicca su &#8220;Return&#8221; (o &#8220;Done&#8221;) della tastiera.</p>
<p style="text-align: center;"><a href="http://www.bubidevs.net/wp-content/uploads/2010/03/Schermata-2010-03-16-a-11.37.06.png"><img class="alignnone size-full wp-image-4809" title="Schermata 2010-03-16 a 11.37.06" src="http://www.bubidevs.net/wp-content/uploads/2010/03/Schermata-2010-03-16-a-11.37.06.png" alt="" width="414" height="770" /></a></p>
<p>Spero di avervi mostrato qualcosa che vi possa tornare utile, se avete richieste scrivetemi utilizzando <a href="http://www.bubidevs.net/contattami/">questo form</a> oppure direttamente su <a href="http://twitter.com/bubidevs">Twitter</a>! Alla prossima!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bubidevs.net/2010/03/16/la-posta-di-bubidevs-7-inserire-una-uitextfiel-in-una-uiviewalert/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

