<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8932689419389118801</id><updated>2024-09-02T01:51:56.535+09:00</updated><category term="iOS5"/><category term="UIImageView"/><category term="NSDate"/><category term="Twitter"/><category term="UIActivityIndicatorView"/><category term="UITableView"/><category term="iOS"/><category term="iOS5. NSNotification"/><category term="iPod"/><category term="others"/><title type='text'>HLabs iPhone 開発記</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://hlabs-ios.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8932689419389118801/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://hlabs-ios.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>h666</name><uri>http://www.blogger.com/profile/14783516542305941022</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8932689419389118801.post-9032198987535227005</id><published>2011-12-13T12:31:00.000+09:00</published><updated>2011-12-13T12:31:56.340+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS5"/><category scheme="http://www.blogger.com/atom/ns#" term="NSDate"/><title type='text'>Twitterのように経過時間を取得する</title><content type='html'>Twitterのように投稿時刻から現在までの経過時間を表示したい場合はNSDateのtimeIntervalSinceNowメソッドを使うとよい。NSTimeIntervalはdouble型である。&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;NSDate *start = [NSDate date];&lt;br /&gt;NSTimeInterval timeInterval = [start timeIntervalSinceNow];&lt;/span&gt;&lt;div&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// 経過時間を秒数で表示。ミリセカンド単位まで測ってくれる模様。&lt;/span&gt;&lt;div&gt;








&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;s1&quot;&gt;NSLog&lt;/span&gt;(&lt;span class=&quot;s2&quot;&gt;@&quot;%f秒前&quot;&lt;/span&gt;, -timeInterval);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// 経過時間を単位時間数で表示。doubleからint型にしている。&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;s1&quot;&gt;NSLog&lt;/span&gt;(&lt;span class=&quot;s2&quot;&gt;@&quot;%i時間前&quot;&lt;/span&gt;, (&lt;span class=&quot;s3&quot;&gt;int&lt;/span&gt;)-timeInterval/&lt;span class=&quot;s4&quot;&gt;3600&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;a href=&quot;http://stackoverflow.com/questions/741830/getting-the-time-elapsed-objective-c&quot;&gt;http://stackoverflow.com/questions/741830/getting-the-time-elapsed-objective-c&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hlabs-ios.blogspot.com/feeds/9032198987535227005/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://hlabs-ios.blogspot.com/2011/12/twitter.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8932689419389118801/posts/default/9032198987535227005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8932689419389118801/posts/default/9032198987535227005'/><link rel='alternate' type='text/html' href='http://hlabs-ios.blogspot.com/2011/12/twitter.html' title='Twitterのように経過時間を取得する'/><author><name>h666</name><uri>http://www.blogger.com/profile/14783516542305941022</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8932689419389118801.post-3871136719534288356</id><published>2011-11-30T14:51:00.001+09:00</published><updated>2011-11-30T15:26:33.438+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS5"/><category scheme="http://www.blogger.com/atom/ns#" term="Twitter"/><title type='text'>iOSのTwitterフレームワークでツイートするには？</title><content type='html'>iOS5になってからTwitterがネイティブでサポートされるようになったことはご存知の通りである。以下はアプリ内からツイートするためのサンプルコードである。&lt;br /&gt;
&lt;br /&gt;
&lt;script class=&quot;brush: cpp&quot; type=&quot;syntaxhighlighter&quot;&gt;
&lt;![CDATA[
if ([TWTweetComposeViewController canSendTweet]) 
{
   // Create account store, followed by a twitter account identifier
   // At this point, twitter is the only account type available
   ACAccountStore *account = [[ACAccountStore alloc] init];
   ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
            
   // Request access from the user to access their Twitter account
   [account requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) 
   {
      // Did user allow us access?
      if (granted == YES)
      {
         // Populate array with all available Twitter accounts
         NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];
                     
         // Sanity check
         if ([arrayOfAccounts count] &gt; 0) 
         {
            // Use first account
            ACAccount *acct = [arrayOfAccounts objectAtIndex:0];
                         
            // Build a twitter request
            TWRequest *postRequest = [[TWRequest alloc] initWithURL: [NSURL URLWithString:@&quot;http://api.twitter.com/1/statuses/update.json&quot;] parameters:[NSDictionary dictionaryWithObject:inputTextView.text forKey:@&quot;status&quot;] requestMethod:TWRequestMethodPOST];
                         
            // Post the request
            [postRequest setAccount:acct];
                         
            // Block handler to manage the response
            [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) 
            {
               NSLog(@&quot;Twitter response, HTTP response: %i&quot;, [urlResponse statusCode]);
            }];
         }
      }
   }];
}
]]&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
コードは&lt;a href=&quot;http://iphonedevelopertips.com/core-services/ios-5-twitter-framework-part-1.html&quot; target=&quot;_blank&quot;&gt;こちらのサイト&lt;/a&gt;のものを拝借している。&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hlabs-ios.blogspot.com/feeds/3871136719534288356/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://hlabs-ios.blogspot.com/2011/11/iostwitter.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8932689419389118801/posts/default/3871136719534288356'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8932689419389118801/posts/default/3871136719534288356'/><link rel='alternate' type='text/html' href='http://hlabs-ios.blogspot.com/2011/11/iostwitter.html' title='iOSのTwitterフレームワークでツイートするには？'/><author><name>h666</name><uri>http://www.blogger.com/profile/14783516542305941022</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8932689419389118801.post-6508881567067548276</id><published>2011-11-30T14:03:00.001+09:00</published><updated>2011-11-30T14:41:42.564+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="UIImageView"/><title type='text'>画像をフェードインさせる</title><content type='html'>画像をすっとフェードインさせたいときはView Animationを使うのが手軽でよい。&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;imageView.alpha = 0;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;[UIView beginAnimations:@&quot;fadeIn&quot; context:nil];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;[UIView setAnimationDuration:0.3];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;imageView.alpha = 1;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;[UIView commitAnimations];&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;例えば非同期で画像をロードして表示する場合、突然絵が現れるのは無骨だが、フェードインさせると眼にやさしいというか見栄えがよかったりする。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://hlabs-ios.blogspot.com/2011/11/blog-post_29.html&quot; target=&quot;_blank&quot;&gt;UIActivityIndicatorViewのくるくる&lt;/a&gt;や&lt;a href=&quot;http://hlabs-ios.blogspot.com/2011/11/blog-post.html&quot; target=&quot;_blank&quot;&gt;画像の非同期ロード&lt;/a&gt;と組み合わせるのがグッド◎</content><link rel='replies' type='application/atom+xml' href='http://hlabs-ios.blogspot.com/feeds/6508881567067548276/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://hlabs-ios.blogspot.com/2011/11/blog-post_30.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8932689419389118801/posts/default/6508881567067548276'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8932689419389118801/posts/default/6508881567067548276'/><link rel='alternate' type='text/html' href='http://hlabs-ios.blogspot.com/2011/11/blog-post_30.html' title='画像をフェードインさせる'/><author><name>h666</name><uri>http://www.blogger.com/profile/14783516542305941022</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8932689419389118801.post-3642263645917861551</id><published>2011-11-29T23:32:00.001+09:00</published><updated>2011-11-30T00:08:02.472+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS5. NSNotification"/><title type='text'>NSNotification - 通知センターの使い方</title><content type='html'>iOSにおいて通知センターは、イベントの登録とイベントハンドラの指定を担うものである。もちろんnotificationの種類にはもともと用意されているものも多くあり、これはJavascriptにおけるイベントのonMouseOverなどに似ている。&lt;br /&gt;
NSNotificationは異なるオブジェクト間でコミュニケーションをとりたいときに役立つ。&lt;br /&gt;
以下のコードはNSNotificationCenterの使用例である。&lt;br /&gt;
&lt;script class=&quot;brush: cpp&quot; type=&quot;syntaxhighlighter&quot;&gt;
&lt;![CDATA[
@implementation TestClass

- (id) init
{
    self = [super init];
    if (!self) return nil;

    // &quot;TestNotification&quot;というイベントが発生した場合に通知するよう、通知センターにイベント名を登録しておく。
    // object:nilとすることで、イベントの送り主を食わず嫌いしない。
    // 一方でobject:に特定のオブジェクトを指定した場合、その送り主からのイベントのみ通知してもらえる。

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(receiveTestNotification:) 
                                                 name:@&quot;TestNotification&quot;
                                               object:nil];
    // NSNotificationCenterから外す場合は以下のようにする。
    [[NSNotificationCenter defaultCenter] removeObserver:self];

    return self;
}

// &quot;TestNotification&quot;というイベントが通知されたときに呼ばれるメソッド。
// Javascriptでイベントハンドラがeventを引数にするが如く、NSNotification*を受け取る。
- (void) receiveTestNotification:(NSNotification *) notification
{
　　 // [notification name]はここでは&quot;TestNotification&quot;となるが、
    // 複数イベントにこのメソッドを使用した場合はそれぞれのイベント名となる。

    if ([[notification name] isEqualToString:@&quot;TestNotification&quot;])
        NSLog (@&quot;Successfully received the test notification!&quot;);
}

@end

- (void) someMethod
{
    // &quot;TestNotification&quot;という名のイベントが発生したことを通知センターに知らせる。
    // object:selfとしているので、全てのTestClassインスタンスは&quot;TestNotification&quot;イベントの通知を受ける。
    // その結果としてreceiveTestNotificationメソッドが呼ばれることになる。
    [[NSNotificationCenter defaultCenter] postNotificationName:@&quot;TestNotification&quot; object:self];
}
]]&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
この例で言うと、receiveTestNotificationメソッドがJavascriptのイベント発生後に実行されるコールバック関数に似ている。&lt;br /&gt;
&lt;br /&gt;
サンプルコードは&lt;a href=&quot;http://stackoverflow.com/questions/2191594/how-to-send-and-receive-message-through-nsnotificationcenter-in-objective-c&quot; target=&quot;_blank&quot;&gt;こちら&lt;/a&gt;を参考に掲載。</content><link rel='replies' type='application/atom+xml' href='http://hlabs-ios.blogspot.com/feeds/3642263645917861551/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://hlabs-ios.blogspot.com/2011/11/nsnotification.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8932689419389118801/posts/default/3642263645917861551'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8932689419389118801/posts/default/3642263645917861551'/><link rel='alternate' type='text/html' href='http://hlabs-ios.blogspot.com/2011/11/nsnotification.html' title='NSNotification - 通知センターの使い方'/><author><name>h666</name><uri>http://www.blogger.com/profile/14783516542305941022</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8932689419389118801.post-7482920430942179013</id><published>2011-11-29T22:28:00.001+09:00</published><updated>2011-11-30T15:17:33.431+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iPod"/><category scheme="http://www.blogger.com/atom/ns#" term="others"/><title type='text'>iPod Nanoを腕時計に！</title><content type='html'>iPod Nanoを腕時計にしてくれる&lt;a href=&quot;http://lunatik.com/&quot; target=&quot;_blank&quot;&gt;tiktok, lunatik&lt;/a&gt;がかっこよさそう。&lt;br /&gt;
シルバー、ブラックをはじめ、赤・青・黄などのカラーラインアップがある模様。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVtYJ6unZiSfeVVWdr0m0lzpzOBQNbrI_YzGpOZemkR-Spe1B4KLzIEWEqU2Nje0HEtWXdT9f7Muz10t0doGOBaBW6cSqmbk4NlZ-3njO_jKnjQyoKPY3tFr-PM6Ah3-tenVWg3qAlKjc/s1600/tiktok.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;179&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVtYJ6unZiSfeVVWdr0m0lzpzOBQNbrI_YzGpOZemkR-Spe1B4KLzIEWEqU2Nje0HEtWXdT9f7Muz10t0doGOBaBW6cSqmbk4NlZ-3njO_jKnjQyoKPY3tFr-PM6Ah3-tenVWg3qAlKjc/s320/tiktok.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.kickstarter.com/&quot; target=&quot;_blank&quot;&gt;Kickstarter&lt;/a&gt;という資金調達支援サービスを通じて$943,000以上も集めて話題になったとか。&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, &#39;times New Roman&#39;; font-size: 14px; line-height: 22px;&quot;&gt;この手があったか！と思い知らされる有名プロジェクトの産物だ。&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, &#39;times New Roman&#39;; font-size: 14px; line-height: 22px;&quot;&gt;アップルの洗練されたデザインをうまく活かした素敵なプロダクトである。&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
強いて言えばiPod Nanoにbluetoothステレオが内蔵で欲しいところ。とはいえ、小型bluetooth対応のトランスミッタを装着すればワイヤレスで音楽再生が可能である。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://lunatik.com/&quot;&gt;http://lunatik.com/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.co.jp/gp/product/B0054Q9114/ref=as_li_tf_il?ie=UTF8&amp;tag=haruo666-22&amp;linkCode=as2&amp;camp=247&amp;creative=1211&amp;creativeASIN=B0054Q9114&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://ws.assoc-amazon.jp/widgets/q?_encoding=UTF8&amp;Format=_SL160_&amp;ASIN=B0054Q9114&amp;MarketPlace=JP&amp;ID=AsinImage&amp;WS=1&amp;tag=haruo666-22&amp;ServiceVersion=20070822&quot; &gt;&lt;/a&gt;&lt;img src=&quot;http://www.assoc-amazon.jp/e/ir?t=haruo666-22&amp;l=as2&amp;o=9&amp;a=B0054Q9114&quot; width=&quot;1&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; style=&quot;border:none !important; margin:0px !important;&quot; /&gt;
&lt;a href=&quot;http://www.amazon.co.jp/gp/product/B004SH40BQ/ref=as_li_tf_il?ie=UTF8&amp;tag=haruo666-22&amp;linkCode=as2&amp;camp=247&amp;creative=1211&amp;creativeASIN=B004SH40BQ&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://ws.assoc-amazon.jp/widgets/q?_encoding=UTF8&amp;Format=_SL160_&amp;ASIN=B004SH40BQ&amp;MarketPlace=JP&amp;ID=AsinImage&amp;WS=1&amp;tag=haruo666-22&amp;ServiceVersion=20070822&quot; &gt;&lt;/a&gt;&lt;img src=&quot;http://www.assoc-amazon.jp/e/ir?t=haruo666-22&amp;l=as2&amp;o=9&amp;a=B004SH40BQ&quot; width=&quot;1&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; style=&quot;border:none !important; margin:0px !important;&quot; /&gt;</content><link rel='replies' type='application/atom+xml' href='http://hlabs-ios.blogspot.com/feeds/7482920430942179013/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://hlabs-ios.blogspot.com/2011/11/ipod-nano.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8932689419389118801/posts/default/7482920430942179013'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8932689419389118801/posts/default/7482920430942179013'/><link rel='alternate' type='text/html' href='http://hlabs-ios.blogspot.com/2011/11/ipod-nano.html' title='iPod Nanoを腕時計に！'/><author><name>h666</name><uri>http://www.blogger.com/profile/14783516542305941022</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVtYJ6unZiSfeVVWdr0m0lzpzOBQNbrI_YzGpOZemkR-Spe1B4KLzIEWEqU2Nje0HEtWXdT9f7Muz10t0doGOBaBW6cSqmbk4NlZ-3njO_jKnjQyoKPY3tFr-PM6Ah3-tenVWg3qAlKjc/s72-c/tiktok.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8932689419389118801.post-4548149355894938638</id><published>2011-11-29T12:44:00.001+09:00</published><updated>2011-11-29T20:48:23.355+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS5"/><category scheme="http://www.blogger.com/atom/ns#" term="UIImageView"/><title type='text'>iOS5で画像を非同期ロードして表示するには？</title><content type='html'>iOS5になってからは自動メモリ管理(automatic reference counting)やNSURLConnectionのデリゲート仕様の変更などにより、従来のコードでは画像をうまく非同期ロードできない場合がある。&lt;br /&gt;
&lt;br /&gt;
そんなときは次のNSURLConnectionのクラスメソッドを実装すればよい。&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;+ (void)sendAsynchronousRequest:(&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;a href=&quot;http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURLRequest_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSURLRequest&quot; style=&quot;color: #3366cc; text-decoration: none;&quot;&gt;NSURLRequest&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;*)&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;em style=&quot;font-style: italic;&quot;&gt;request&lt;/em&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;queue:(&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;a href=&quot;http://developer.apple.com/library/mac/documentation/Cocoa/Reference/NSOperationQueue_class/Reference/Reference.html#//apple_ref/doc/c_ref/NSOperationQueue&quot; style=&quot;color: #3366cc; text-decoration: none;&quot;&gt;NSOperationQueue&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;*)&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;em style=&quot;font-style: italic;&quot;&gt;queue&lt;/em&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;completionHandler:(void (^)(NSURLResponse*, NSData*, NSError*))&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;em style=&quot;font-style: italic;&quot;&gt;handler&lt;/em&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
iOS5でもかつてのNSURLConnectionデリゲートメソッド(現在はNSURLConnectionData protocolのものか)によって非同期通信が実現できないわけではないらしいが、マルチスレッドでアプリを動かす場合には注意が必要とのこと。いずれにしても今後は&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;sendAsynchronousRequest&lt;/span&gt;を利用した方がベターということであろうか。&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)&lt;br /&gt;- (void)connectionDidFinishLoading:(NSURLConnection *)connection &lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
iOS4.3以前であれば、次のようなライブラリがあり、かつてはよく使用されていたと思われる。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://github.com/nicklockwood/AsyncImageView&quot; target=&quot;_blank&quot;&gt;AsyncImageView&lt;/a&gt;&lt;br /&gt;
UIImageViewを継承したクラスライブラリ。&lt;br /&gt;
非同期通信で画像をロードし、UIが固まるのを防いでくれる。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://allseeing-i.com/ASIHTTPRequest/&quot; target=&quot;_blank&quot;&gt;ASIHTTPRequest&lt;/a&gt;&lt;br /&gt;
CFNetwork APIのラッパーで非同期通信をラクにするライブラリ。&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hlabs-ios.blogspot.com/feeds/4548149355894938638/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://hlabs-ios.blogspot.com/2011/11/blog-post.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8932689419389118801/posts/default/4548149355894938638'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8932689419389118801/posts/default/4548149355894938638'/><link rel='alternate' type='text/html' href='http://hlabs-ios.blogspot.com/2011/11/blog-post.html' title='iOS5で画像を非同期ロードして表示するには？'/><author><name>h666</name><uri>http://www.blogger.com/profile/14783516542305941022</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8932689419389118801.post-1961740369074665718</id><published>2011-11-29T12:10:00.001+09:00</published><updated>2011-11-30T13:14:50.880+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS5"/><category scheme="http://www.blogger.com/atom/ns#" term="UIActivityIndicatorView"/><title type='text'>画像とかロードしてるときのくるくる</title><content type='html'>UIActivityIndicatorViewを使うのが一般的。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;UIActivityIndicatorView&lt;span class=&quot;s1&quot;&gt; *spinner = [[&lt;/span&gt;UIActivityIndicatorView&lt;span class=&quot;s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;alloc&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;initWithFrame&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;CGRectMake&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;135&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;)];&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; [spinner &lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;startAnimating&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;];&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; [&lt;span class=&quot;s4&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;s5&quot;&gt;view&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;addSubview&lt;/span&gt;:spinner];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; //いろいろたのしいことしませふ&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; [spinner stopAnimating];&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
デフォルトの設定では&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;stopAnimating&lt;/span&gt;をした段階でくるくるは非表示になる。&lt;br /&gt;
これは&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;UIActivityIndicatorView&lt;/span&gt;の&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;hidesWhenStopped&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Courier, Consolas, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 14px;&quot;&gt;というプロパティのデフォルト値が&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;YES&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Courier, Consolas, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 14px;&quot;&gt;になっているためである。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hlabs-ios.blogspot.com/feeds/1961740369074665718/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://hlabs-ios.blogspot.com/2011/11/blog-post_29.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8932689419389118801/posts/default/1961740369074665718'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8932689419389118801/posts/default/1961740369074665718'/><link rel='alternate' type='text/html' href='http://hlabs-ios.blogspot.com/2011/11/blog-post_29.html' title='画像とかロードしてるときのくるくる'/><author><name>h666</name><uri>http://www.blogger.com/profile/14783516542305941022</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8932689419389118801.post-8025202383416125497</id><published>2011-11-29T11:53:00.001+09:00</published><updated>2011-11-29T12:33:03.502+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS5"/><category scheme="http://www.blogger.com/atom/ns#" term="UITableView"/><title type='text'>TableViewのヘッダーのスタイルを変更するには？</title><content type='html'>グルーピングスタイルのTableViewの文字色やフォントサイズといったスタイルを変更するにはどうしたらよいか。&lt;br /&gt;
&lt;br /&gt;
UITableViewDataSource Protocolにある&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;a href=&quot;http://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewDataSource_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UITableViewDataSource/tableView:titleForHeaderInSection:&quot; style=&quot;background-color: white; color: #003366; font-family: Courier, Consolas, monospace; font-size: 13px; text-decoration: none; white-space: nowrap;&quot;&gt;–&amp;nbsp;tableView:titleForHeaderInSection:&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
を実装すれば、ヘッダーのタイトルを出力できるが、スタイルまでは変えることができない。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
UITableViewDelegate Protocolにある次の二つのメソッドを実装すればデザインもまとめて変更できる。&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; font-family: Courier, Consolas, monospace; font-size: 13px;&quot;&gt;- (&lt;/span&gt;&lt;a href=&quot;http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/doc/c_ref/UIView&quot; style=&quot;background-color: white; color: #003366; font-family: Courier, Consolas, monospace; font-size: 13px; text-decoration: none;&quot;&gt;UIView&lt;/a&gt;&lt;span style=&quot;background-color: white; font-family: Courier, Consolas, monospace; font-size: 13px;&quot;&gt;&amp;nbsp;*)tableView:(&lt;/span&gt;&lt;a href=&quot;http://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableView_Class/Reference/Reference.html#//apple_ref/doc/c_ref/UITableView&quot; style=&quot;background-color: white; color: #003366; font-family: Courier, Consolas, monospace; font-size: 13px; text-decoration: none;&quot;&gt;UITableView&lt;/a&gt;&lt;span style=&quot;background-color: white; font-family: Courier, Consolas, monospace; font-size: 13px;&quot;&gt;&amp;nbsp;*)&lt;/span&gt;&lt;em style=&quot;background-color: white; font-family: &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; font-size: 13px;&quot;&gt;tableView&lt;/em&gt;&lt;span style=&quot;background-color: white; font-family: Courier, Consolas, monospace; font-size: 13px;&quot;&gt;&amp;nbsp;viewForHeaderInSection:(&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: Courier, Consolas, monospace; font-size: 13px;&quot;&gt;NSInteger&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: Courier, Consolas, monospace; font-size: 13px;&quot;&gt;)&lt;/span&gt;&lt;em style=&quot;background-color: white; font-family: &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; font-size: 13px;&quot;&gt;section&lt;/em&gt;&lt;span style=&quot;background-color: white; font-family: Courier, Consolas, monospace; font-size: 13px;&quot;&gt;- (&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: Courier, Consolas, monospace; font-size: 13px;&quot;&gt;CGFloat&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: Courier, Consolas, monospace; font-size: 13px;&quot;&gt;)tableView:(&lt;/span&gt;&lt;a href=&quot;http://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableView_Class/Reference/Reference.html#//apple_ref/doc/c_ref/UITableView&quot; style=&quot;background-color: white; color: #003366; font-family: Courier, Consolas, monospace; font-size: 13px; text-decoration: none;&quot;&gt;UITableView&lt;/a&gt;&lt;span style=&quot;background-color: white; font-family: Courier, Consolas, monospace; font-size: 13px;&quot;&gt;&amp;nbsp;*)&lt;/span&gt;&lt;em style=&quot;background-color: white; font-family: &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; font-size: 13px;&quot;&gt;tableView&lt;/em&gt;&lt;span style=&quot;background-color: white; font-family: Courier, Consolas, monospace; font-size: 13px;&quot;&gt;&amp;nbsp;heightForHeaderInSection:(&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: Courier, Consolas, monospace; font-size: 13px;&quot;&gt;NSInteger&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: Courier, Consolas, monospace; font-size: 13px;&quot;&gt;)&lt;/span&gt;&lt;em style=&quot;background-color: white; font-family: &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; font-size: 13px;&quot;&gt;section&lt;/em&gt;&lt;/div&gt;
&lt;br /&gt;
heightForHeaderInSectionも一緒に実装しないと表示がへんになる。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://stackoverflow.com/questions/6922808/how-can-we-change-the-font-of-tableview-header&quot;&gt;http://stackoverflow.com/questions/6922808/how-can-we-change-the-font-of-tableview-header&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://hlabs-ios.blogspot.com/feeds/8025202383416125497/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://hlabs-ios.blogspot.com/2011/11/tableview.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8932689419389118801/posts/default/8025202383416125497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8932689419389118801/posts/default/8025202383416125497'/><link rel='alternate' type='text/html' href='http://hlabs-ios.blogspot.com/2011/11/tableview.html' title='TableViewのヘッダーのスタイルを変更するには？'/><author><name>h666</name><uri>http://www.blogger.com/profile/14783516542305941022</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8932689419389118801.post-5977143252910648759</id><published>2011-11-29T11:45:00.001+09:00</published><updated>2011-11-29T11:47:18.050+09:00</updated><title type='text'>iOS 開発ブログ設置</title><content type='html'>iOS開発入門者として、疑問に思ったことや問題の解決策などを記していくことにする。</content><link rel='replies' type='application/atom+xml' href='http://hlabs-ios.blogspot.com/feeds/5977143252910648759/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://hlabs-ios.blogspot.com/2011/11/ios.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8932689419389118801/posts/default/5977143252910648759'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8932689419389118801/posts/default/5977143252910648759'/><link rel='alternate' type='text/html' href='http://hlabs-ios.blogspot.com/2011/11/ios.html' title='iOS 開発ブログ設置'/><author><name>h666</name><uri>http://www.blogger.com/profile/14783516542305941022</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>