<?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>CrossBridge</title>
	<atom:link href="http://www.crossbridge.biz/feed" rel="self" type="application/rss+xml" />
	<link>http://www.crossbridge.biz</link>
	<description>iOS/Andoirdを中心としたアプリケーションの企画/開発</description>
	<lastBuildDate>Thu, 23 Feb 2012 09:33:45 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>UITableViewを表示するカスタムUIAlertView</title>
		<link>http://www.crossbridge.biz/cbalerttableview</link>
		<comments>http://www.crossbridge.biz/cbalerttableview#comments</comments>
		<pubDate>Tue, 21 Feb 2012 12:21:40 +0000</pubDate>
		<dc:creator>kkato</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[UIAlertView]]></category>
		<category><![CDATA[UITabaleView]]></category>

		<guid isPermaLink="false">http://www.crossbridge.biz/?p=265</guid>
		<description><![CDATA[UIAlertViewにUITableViewを表示するカスタムUIAlertView(CBAlertTableViewクラス)を作ってみました。 ソースコードはこちらで公開しています。ライセンスはApache Lice <a href="http://www.crossbridge.biz/cbalerttableview">more</a>]]></description>
			<content:encoded><![CDATA[<p>UIAlertViewにUITableViewを表示するカスタムUIAlertView(<strong>CBAlertTableViewクラス</strong>)を作ってみました。</p>
<p>ソースコードはこちらで公開しています。ライセンスはApache License 2.0です。<br />
<a href="https://github.com/CrossBridge/CBAlertTableView" target="_blank">https://github.com/CrossBridge/CBAlertTableView</a></p>
<p><img class="alignnone  wp-image-298" title="スクリーンショット" src="http://www.crossbridge.biz/wp-content/uploads/2012/02/CBAlertTableView01.png" alt="" width="221" height="430" /></p>
<p>シンプルなものにしたかったので、生成時にNSStringのNSArrayを指定して、それらの文字列をTableViewに表示しています。ユーザーに項目を選択させるだけであれば十分だと思います。</p>
<p>使い方は続きからどうぞ。</p>
<p><span id="more-265"></span></p>
<h2>インストール</h2>
<p>CBAlertTableView.mとCBAlertTableView.hを利用するXcodeのプロジェクトにコピーしてください。</p>
<p>ARCは利用していないのでiOS5以降でARCを利用しているプロジェクトの場合はこのファイルに対してはオフにすることを忘れずに。</p>
<h2>利用方法</h2>
<p>まず、利用するクラスで<span style="color: #ff0000;"><strong>CBAlertTableViewDelegate</strong></span>を実装します。</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@protocol</span> CBAlertTableViewDelegate
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>selectedIndex<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>index;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>canceled;
<span style="color: #a61390;">@end</span></pre></div></div>

<ul>
<li>selectedIndex:(int)indexメソッド：セルが選択された時に呼び出される</li>
<li>canceled：キャンセルボタンが押された時に呼び出される</li>
</ul>
<p>次に、<span style="color: #ff0000;"><strong>CBAlertTableViewクラス</strong></span>を生成します。生成用のクラスメソッドがあるので呼び出します。</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;">id</span><span style="color: #002200;">&#41;</span>alertTabaleViewWithStringArray<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>stringArray
                              titile<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>title
                   cancelButtonTitle<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>cancelButtonTitle
                            delegate<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>delegate;</pre></div></div>

<ul>
<li>stringArray：UITableViewに表示させたい 文字列</li>
<li>title：AlertViewに表示されるタイトル</li>
<li>cancelButtonTitle：キャンセルボタンに表示させるタイトル</li>
<li>delegate：CBAlertTableViewDelegateを実装したクラスを指定。選択時、キャンセル時に呼び出される。</li>
</ul>
<p>あとは通常のUIAlertViewと同様に<span style="color: #ff0000;"><strong>showメソッド</strong></span>を呼び出せば表示されます。</p>
<h2>ソースコード</h2>
<p>ソースコードはこちらで公開しています。ライセンスはApache License 2.0です。</p>
<p><a href="https://github.com/CrossBridge/CBAlertTableView" target="_blank">https://github.com/CrossBridge/CBAlertTableView</a></p>
<p><iframe style="border: none;" src="http://rcm-jp.amazon.co.jp/e/cm?t=crossbridge-22&amp;o=9&amp;p=16&amp;l=st1&amp;mode=books-jp&amp;search=iPhone cocoa objective-c&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" width="468" height="336"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.crossbridge.biz/cbalerttableview/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

