2012年5月29日火曜日

type:video

audioはひとまずpost_urlに飛ばすようにした。特に問題なく動いている様子。videoはエンベッドのコードがpostによって違うようで、youtubeだったり別の何かだったり場合によってはFlashだったりするみたい。とりあえずUIWebView貼るためにwidthとheightを正規表現で抜くとこまで書いた。

#define reg(x) [x firstMatchInString:[contArr objectAtIndex:i] options:0 range:NSMakeRange(0, [[contArr objectAtIndex:i]length])]


}else if([[typeArr objectAtIndex:i]isEqualToString:@"video"]){
 NSError *error;
 NSRegularExpression *wpat=[NSRegularExpression regularExpressionWithPattern:@"width=['\"]?([0-9]+)" options:0 error:&error];
 NSRegularExpression *hpat=[NSRegularExpression regularExpressionWithPattern:@"height=['\"]?([0-9]+)" options:0 error:&error];
 if(error) NSLog(@"error.");
 else{
  NSTextCheckingResult *wmatch=reg(wpat),*hmatch=reg(hpat);
  NSLog(@"w:%@ / ",[[contArr objectAtIndex:i]substringWithRange:[wmatch rangeAtIndex:1]]);
  NSLog(@"h:%@",[[contArr objectAtIndex:i]substringWithRange:[hmatch rangeAtIndex:1]]);
 }
}

できた。perlとかと比べて正規表現の処理にエレガントさがない。あとはUIWebView貼るだけ。ようやくここまで来た。

夜は三く@新福島でかけ並ごはん。煮干系はなかなか外れがない。美味い。ちなみにボクサーの井岡さんとエンカウントしてシールもらった。このシール中津の弥七でも貼ってたしラーメン好きなんかな。

2012年5月27日日曜日

album_art

とりあえずaudioのジャケット画像を非同期で引っ張ってきて真ん中に表示させるためのUIImageViewのサブクラスを作った。あとはこの下にボタン置いてタッチしたらpost_urlをUIWebViewで開く感じで十分なようにも思う。Tumblrの中の人にはaudio_urlについて質問中。サポートチームに投げてなんかわかったら連絡するわーとのこと。

AlbumArt.m
- (id)initWithFrame:(CGRect)frame aaurl:(NSString *)cont
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
  if([cont isEqual:[NSNull null]]){
   self.image=[UIImage imageNamed:@"ina"];
   return self;
  }
  if(!ai) ai=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
  [ai setCenter:self.center];[self addSubview:ai];[ai startAnimating];
  data=[[NSMutableData alloc]initWithCapacity:0];
  NSURLRequest *req=[NSURLRequest 
         requestWithURL:[NSURL URLWithString:cont]
         cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
  conne=[[NSURLConnection alloc]initWithRequest:req delegate:self];
    }
    return self;
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
 if([((NSHTTPURLResponse *)response) statusCode]!=200){
  data=[[NSMutableData alloc]initWithData:UIImagePNGRepresentation([UIImage imageNamed:@"ina"])];
  self.image=[UIImage imageWithData:data];
  [self abort];
 }
 else [data setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)rdata{
 [data appendData:rdata];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
 [self abort];
 NSLog(@"error.");
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
 [ai removeFromSuperview];
 UIImage *aa=[UIImage imageWithData:data];
 UIImageView *aav=[[UIImageView alloc]initWithImage:aa];
 UIImage *border=[UIImage imageNamed:@"gray"];
 UIImageView *borderv=[[UIImageView alloc]initWithImage:border];
 [aav setFrame:CGRectMake(3,3,204,204)];
 [borderv setFrame:CGRectMake(0,0,210,210)];
 [self addSubview:borderv];[self addSubview:aav];
 [self setFrame:CGRectMake((self.frame.size.width-210)/2,(self.frame.size.height-210)/2,210,210)];
}
-(void)abort{
 if(conne!=nil){[conne cancel];conne=nil;}
 if(data!=nil) data=nil;
}

できた。

勘違い

audio_urlにリクエスト投げて返ってきたのはpermission deniedだったみたい…。statusCode拾ったら403やった。最初から確認しとけばよかった。とりあえずtumblrのなかの人に聞いてみようかな。
昼は河童ラーメン本舗工場店で河童ラーメンとごはん小。予想してたよりは全然いけた。今度は黒河童いってみるか。

type:audio

tumblrのAPIから返ってくるaudioのJSONにaudio_urlっていうエレメントがあった。APIのドキュメントには一切記載がない。このへんtumblrの中の人ら超テキトーっぽいからなー。とりあえずそのurlにリクエスト投げてみたらデータは返ってきた。レスポンスのヘッダはこんな感じ。

2012-05-27 00:09:33.311 tm0001[1433:f803] {
"Cache-Control" = "no-cache, must-revalidate";
Connection = close;
"Content-Encoding" = gzip;
"Content-Length" = 780;
"Content-Type" = "text/html; charset=UTF-8";
Date = "Sat, 26 May 2012 15:09:33 GMT";
Expires = "Fri, 01 Jan 1990 00:00:00 GMT";
P3P = "CP=\"ALL ADM DEV PSAi COM OUR OTRo STP IND ONL\"";
Pragma = "no-cache";
Server = Apache;
Vary = "Accept-Encoding";
"X-Tumblr-Usec" = "D=27180";
}

gzip?htmlが圧縮されてんの?全然分からん。返ってくるデータも容量的に小さいし、とりあえずaudio関連のライブラリにぶち込んで試してみよう。って偉そうに書いてるけど今からゼロから調べるんやけどね。
昨晩は愛媛出張から帰ってきてそのまま光龍益@桜ノ宮で特製ラーメン。まー、普通。今月まだ19杯目。

2012年5月23日水曜日

chatにふきだし

ふきだし、とりあえずつけてみた。
}else if([[typeArr objectAtIndex:i]isEqualToString:@"chat"]){ //chat
 UIView *chatBase=[[UIView alloc]init];
 CGFloat npy=0;int j=1;
 for(id dialogue in [contArr objectAtIndex:i]){
  UILabel *np=[[UILabel alloc]init];np.numberOfLines=0;
  np.text=[NSString stringWithFormat:@"%@%@",[dialogue objectForKey:@"label"],[dialogue objectForKey:@"phrase"]];np.font=sf(15);
  CGSize npsize=[np.text sizeWithFont:np.font constrainedToSize:CGSizeMake(sw-60,sh-50) lineBreakMode:UILineBreakModeTailTruncation];
  np.textColor=[UIColor blackColor];np.backgroundColor=[UIColor clearColor];np.frame=CGRectMake(30,npy,npsize.width,npsize.height);
  [chatBase addSubview:np];
  npy+=npsize.height+20;j++;
  //if(j>[[contArr objectAtIndex:i]count]) break;
  UIImage *line=[UIImage imageNamed:@"gray"];
  UIImageView *linev=[[UIImageView alloc]initWithImage:line];linev.alpha=0.7;[linev setFrame:CGRectMake(25,npy-12,sw-50,4)];
  UIImage *fuki=[UIImage imageNamed:(j%2)?@"fuki":@"fuki2"];
  UIImageView *fukiv=[[UIImageView alloc]initWithImage:fuki];fukiv.alpha=0.7;
  [fukiv setFrame:CGRectMake((j%2)?5:sw-25,npy-12-30,20,30)];
  [chatBase addSubview:linev];[chatBase addSubview:fukiv];
 }
 UIScrollView *chatScr=[[UIScrollView alloc]initWithFrame:CGRectMake(0,30,sw,sh-50)];[postv addSubview:chatScr];
 [chatScr addSubview:chatBase];
 [chatScr setContentSize:CGSizeMake(sw-40, npy)];
}
できた。
これで各自が喋ってる感がちょっとはでたはず。
よるは天天,有@住之江公園に行くも何故かしまってたので急遽岸里から歩いてらーめんコーさんでチャーシューらーめんとライス。角煮級のチャーシューが5枚入ってる上にライスが激盛りで死ぬかと思った。味はあんまり覚えてない。

2012年5月22日火曜日

audioとvideo

audioはAPIから返ってくるのがswfをエンベッドするためのコードなので、そのままだと使えない。UAをiPhoneにしてaudioのポストを公式dashboardでどう表示してるか見てみるとjavascriptでmp3を再生してるみたい。mp3の命名規則はなんとなくわかるのでやろうと思えば無理やりHTMLのパースで抜けると思うが、あまり意味ないよね。とりあえずジャケット画像を出してボタン置いて押せばpostのurlをUIWebViewに貼ってaddSubViewかな。手抜きかな?videoはyoutubeのエンベッド用コードが返ってくるので単純に貼れば済む。その際のUIWebViewのframe.size計算のためにコードからwidthとheightを抜かんといかんな。正規表現でパパっと行けそうなサンプル見つけたので参考にさせて頂く。

Objective-Cで正規表現を使う その2

2012年5月21日月曜日

type:chat

typeがchatのポストのviewがとりあえずできた。あとは吹き出しみたいな奴もつけてみるか。いらんか。
}else if([[typeArr objectAtIndex:i]isEqualToString:@"chat"]){ //chat
 UIView *chatBase=[[UIView alloc]init];
 CGFloat npy=0;int j=1;
 for(id dialogue in [contArr objectAtIndex:i]){
  UILabel *np=[[UILabel alloc]init];np.numberOfLines=0;
  np.text=[NSString stringWithFormat:@"%@%@",[dialogue objectForKey:@"label"],[dialogue objectForKey:@"phrase"]];np.font=sf(15);
  CGSize npsize=[np.text sizeWithFont:np.font constrainedToSize:CGSizeMake(sw-40,sh-50) lineBreakMode:UILineBreakModeTailTruncation];
  np.textColor=[UIColor blackColor];np.backgroundColor=[UIColor whiteColor];np.frame=CGRectMake(20,npy,npsize.width,npsize.height);
  [chatBase addSubview:np];
  npy+=npsize.height+20;j++;
  if(j>[[contArr objectAtIndex:i]count]) break;
  UIImage *line=[UIImage imageNamed:@"gray"];
  UIImageView *linev=[[UIImageView alloc]initWithImage:line];linev.alpha=0.7;[linev setFrame:CGRectMake(20,npy-12,sw-40,5)];
  [chatBase addSubview:linev];   
 }
 UIScrollView *chatScr=[[UIScrollView alloc]initWithFrame:CGRectMake(0,30,sw,sh-50)];[postv addSubview:chatScr];
 [chatScr addSubview:chatBase];
 [chatScr setContentSize:CGSizeMake(sw-40, npy)];
}
できた。あとはaudio,videoか。これができればあとはtimelinestyleも作るか。楽しみは尽きない。gearも復活したことやし、のんびりやろう。
夜は中華そば無限@海老江で塩そばとごはん。これは美味い。閉まるの早いからなかなか来れんけど、今月限定の無限流高井田系食べてみたい。

2012年5月20日日曜日

UI微調整

textとquoteの見た目をちょっと変えた。統一感というか、単純によりよいデザインというか、そのへんを考えて。やっぱり何週間か前のコードでも、改めて見ると色々修正したくなるな。ひとまず下記の通り:
- (void)mkSinglePostView{
 for(int i=[pvArr count];i<[contArr count];i++){
  postv=[[UIView alloc]initWithFrame:self.view.bounds];
  if([[typeArr objectAtIndex:i]isEqualToString:@"text"]){ //text
   NSString *text=[self deltag:[contArr objectAtIndex:i]];
   UITextView *textv=[[UITextView alloc]initWithFrame:CGRectMake(10, 20, sw-20, sh-50)];
   [postv addSubview:textv];
   textv.text=text;
   for(int i=16;i<270;i++){
    textv.font=sf(i);
    if(textv.contentSize.height>sh-50){textv.font=sf(i-1);break;}
   }
   textv.textColor=[UIColor blackColor];textv.backgroundColor=[UIColor clearColor];textv.editable=NO;
   [postv addSubview:textv];
  }else if([[typeArr objectAtIndex:i]isEqualToString:@"photo"]){ //photo
   Photo *photov=[[Photo alloc]initWithFrame:self.view.bounds photourl:[contArr objectAtIndex:i]];
   [postv addSubview:photov];
   [photov loadPhoto];
  }else if([[typeArr objectAtIndex:i]isEqualToString:@"quote"]){ //quote
   UIImage *quoteimg=[UIImage imageNamed:@"quote"];
   UIImageView *quoteimgv=[[UIImageView alloc]initWithImage:quoteimg];
   [quoteimgv setFrame:CGRectMake(5,-10,50,50)];quoteimgv.alpha=0.7;
   [postv addSubview:quoteimgv];
   NSString *quote=[self deltag:[contArr objectAtIndex:i]];
   UITextView *quotev=[[UITextView alloc]initWithFrame:CGRectMake(25, 40, sw-30, sh-70)];
   [postv addSubview:quotev];
   //quotev.text=quote;quotev.font=[UIFont fontWithName:@"Helvetica" size:[quote length]>13?300/[quote length]*(3-[quote length]/150)+15:75];
   quotev.text=quote;
   for(int i=16;i<270;i++){
    quotev.font=sf(i);
    if(quotev.contentSize.height>sh-70){quotev.font=sf(i-1);break;}
   }
   quotev.textColor=[UIColor blackColor];quotev.backgroundColor=[UIColor clearColor];quotev.editable=NO;
   UIImage *line=[UIImage imageNamed:@"gray"];
   UIImageView *linev=[[UIImageView alloc]initWithImage:line];linev.alpha=0.5;[linev setFrame:CGRectMake(15,50,7,quotev.contentSize.height-20)];
   [postv addSubview:linev];   
  }else if([[typeArr objectAtIndex:i]isEqualToString:@"link"]){ //link
   Link *link=[[Link alloc]initWithFrame:CGRectMake(10,30,sw-20,sh-80) string:[[contArr objectAtIndex:i]objectAtIndex:0]];
   [postv addSubview:link];
   NSLog(@"%f",sh-link.origin.y);
   UIImage *openlinkimg=[UIImage imageNamed:@"openlink"],*openlinkimg_on=[UIImage imageNamed:@"openlink_on"];
   UIButton *open=[UIButton buttonWithType:UIButtonTypeCustom];//move.alpha=0.7;
   [open setImage:openlinkimg forState:UIControlStateNormal];[open setImage:openlinkimg_on forState:UIControlStateHighlighted];
   [open setFrame:CGRectMake(10,sh-link.origin.y-30,130,23)];
   [open addTarget:self action:@selector(openLink) forControlEvents:UIControlEventTouchUpInside];
   [postv addSubview:open];
  }

できた。appとして方向性が決まってなかったのを是正した感じかな。そんな大層なもんでもないか。
昼は中華そば鐘馗@東三国で中華そばと半ヤキメシ。美味しい。次はTKG試してみよう。

2012年5月17日木曜日

type:link

Linkのタイトルの下にボタンを置いてタッチすると必要最低限のコントローラを持ったUIWebView(を持ったUIViewController)をaddSubViewして用済みになればkillmeするクラスを作って貼った。特に問題なく稼働。

- (id)initWithURL:(NSString *)string{
 self=[super init];if(self) url=string;
 return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
 // Do any additional setup after loading the view.
 page=[[UIWebView alloc]initWithFrame:self.view.bounds];page.scalesPageToFit=YES;page.delegate=self;[self.view addSubview:page];
 toolbar=[[UIToolbar alloc]initWithFrame:CGRectMake(0, self.view.frame.size.height-36, self.view.frame.size.width,36)];
 toolbar.tintColor=[UIColor blackColor];toolbar.translucent=YES;
 [self.view addSubview:toolbar];
 back=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemRewind target:self action:@selector(back)];
 forward=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFastForward target:self action:@selector(forward)];
 done=[[UIBarButtonItem alloc]initWithTitle:@"done" style:UIBarButtonItemStyleDone target:self action:@selector(killme)];
 NSArray *buttons=[[NSArray alloc]initWithObjects:done,back,forward,nil];
 [toolbar setItems:buttons animated:YES];
 [page loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
}

- (void)webViewDidStartLoad:(UIWebView *)webView{
 if(!ai) ai=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
 [ai setCenter:self.view.center];[self.view addSubview:ai];[ai startAnimating];
 [self update];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView{
 if(ai) [ai removeFromSuperview];
 [self update];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
 //nothing.
}
- (void)update{
 back.enabled=page.canGoBack;
 forward.enabled=page.canGoForward;
}

- (void)killme{[self.view removeFromSuperview];}
- (void)back{if(page.canGoBack)[page goBack];}
- (void)forward{if(page.canGoForward)[page goForward];}

できた。まあこのへんは参考にできる文書が山のようにあるので楽チン。残すはchat、audio、videoか。なんとかなるかな。
昼は3738@長居で特製中華そば。ガラガラ。思ってたよりは美味しかった。今月まだ10杯目。

CTFrameGetLineOrigins

CoreTextで描画した文字のframeの高さを取るだけで死ぬほど苦労した。CTFrameGetLineOriginsってのを使えばいいのはわかったけど参考事例が少なすぎる上に皆バラバラの記述で何が何やらわからん。やっとの思いでたどり着いて宣言プロパティにoriginの入ったcgpointを入れた。これでリンクテキストのしたにボタンを置けた。たったこれだけのことで何時間費やしたのか。またひとつ賢くなった。

#import "LinkedText.h"

@implementation LinkedText

@synthesize origin;

- (id)initWithFrame:(CGRect)frame string:(NSString *)string
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
  NSMutableDictionary *attrDic=[NSMutableDictionary dictionaryWithCapacity:0];
  CTFontRef ctFont=CTFontCreateWithName((__bridge CFStringRef)@"Helvetica",24, NULL);
  [attrDic setObject:(__bridge id)ctFont forKey:(NSString *) kCTFontAttributeName];
  [attrDic setObject:(__bridge id)[UIColor blueColor].CGColor forKey:(NSString *)kCTForegroundColorAttributeName];
  [attrDic setObject:[NSNumber numberWithInt:(int)kCTUnderlineStyleSingle] forKey:(NSString *)kCTUnderlineStyleAttributeName];
  NSMutableAttributedString *linkedText=[[NSMutableAttributedString alloc]initWithString:string attributes:attrDic];
  CGMutablePathRef path=CGPathCreateMutable();
  CTFramesetterRef framesetter= CTFramesetterCreateWithAttributedString((__bridge CFMutableAttributedStringRef)linkedText);;
  CGPathAddRect(path, NULL, self.bounds);
  ctFrame=CTFramesetterCreateFrame(framesetter,CFRangeMake(0, [linkedText length]),path,NULL);
  CFArrayRef lines=CTFrameGetLines(ctFrame);
  CFIndex lastitem=CFArrayGetCount(lines)-1;
  CTFrameGetLineOrigins(ctFrame, CFRangeMake(lastitem,1), &origin);
  CGPathRelease(path);
  self.backgroundColor=[UIColor clearColor];
    }
    return self;
}

できた。originを呼び元のrootのviewcontrollerから参照してボタンを置いて、あとはUIWebViewでリンク先を開くだけ。これはacessTokenを取る時と同じ感じでいけるはず。本当か。

夜は職場の人とサシで御飯食べて更にそこから角力@玉造でコクしょうゆらーめん。美味いが、若干甘いかな。満腹。

2012年5月14日月曜日

NSMutableAttributedString

typeがlinkのpostはtitleを青字の下線で表示すべく色々調べたけど普通にやっても無理みたいでcore text?使わんといかんらしい。とりあえずいろんなサイトから切り貼りでUITextViewのサブクラス作ってみた。

- (id)initWithFrame:(CGRect)frame string:(NSString *)string
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
  NSMutableDictionary *attrDic=[NSMutableDictionary dictionaryWithCapacity:0];
  CTFontRef ctFont=CTFontCreateWithName((__bridge CFStringRef)@"Helvetica",21, NULL);
  [attrDic setObject:(__bridge id)ctFont forKey:(NSString *) kCTFontAttributeName];
  [attrDic setObject:(__bridge id)[UIColor blueColor].CGColor forKey:(NSString *)kCTForegroundColorAttributeName];
  [attrDic setObject:[NSNumber numberWithInt:(int)kCTUnderlineStyleSingle] forKey:(NSString *)kCTUnderlineStyleAttributeName];
  NSMutableAttributedString *linkedText=[[NSMutableAttributedString alloc]initWithString:string attributes:attrDic];
  CGMutablePathRef path=CGPathCreateMutable();
  CTFramesetterRef framesetter= CTFramesetterCreateWithAttributedString((__bridge CFMutableAttributedStringRef)linkedText);;
  CGPathAddRect(path, NULL, self.bounds);
  ctFrame=CTFramesetterCreateFrame(framesetter,CFRangeMake(0, [linkedText length]),path,NULL);
  CGPathRelease(path);
  //self.text=string;self.font=[UIFont fontWithName:@"Helvetica" size:21];self.textColor=[UIColor clearColor];
    }
    return self;
}
- (void)drawRect:(CGRect)rect
{
  CGContextRef context;
    context=UIGraphicsGetCurrentContext();
    CGContextSaveGState(context);
    CGContextTranslateCTM(context, 0, CGRectGetHeight(self.bounds));
    CGContextScaleCTM(context, 1.0f, -1.0f);
    CTFrameDraw(ctFrame, context);
    CGContextRestoreGState(context);
}


UITextViewのサブクラスである必要はなさそうやけど一応。contentSize.height取るために透明色でtextセットしてみたけど、core textのものとは微妙に文字幅、行間が異なるみたいでなんかずれる。ちょっと調べる。
週末は麺や天啓でつけ麺。つけ麺自体はそこそこやけど、〆にスープ割りだけじゃなくて雑炊も選べて、これが実に美味い。今月まだ6杯目。ペースが遅い。

2012年5月7日月曜日

typeがtextのpostはtitleとbodyの境界に線を描画しようと思って色々調べたけど、uiviewのサブクラスを作ってdrawrectをオーバーライドするとかすげー大層な話になってるので1x1pxのpngをuiimageでサイズ変形してaddsubviewした。これで十分かな。あとはquoteのフォントサイズを15〜270のループで回してcontentSize.heightがwindowを超えるいっこ前を取るようにしてびしっとuitextview内に収まるように修正。だいぶ力技やな。contentSizeがaddsubviewする前には取得できないと知らずに若干ハマった。

#define sf(x) [UIFont fontWithName:@"Helvetica" size:x]

}else if([[typeArr objectAtIndex:i]isEqualToString:@"quote"]){ //quote
 UIImage *quoteimg=[UIImage imageNamed:@"quote"];
 UIImageView *quoteimgv=[[UIImageView alloc]initWithImage:quoteimg];
 [quoteimgv setFrame:CGRectMake(10,15,50,50)];quoteimgv.alpha=0.7;
 [postv addSubview:quoteimgv];
 NSString *quote=[self deltag:[contArr objectAtIndex:i]];
 UITextView *quotev=[[UITextView alloc]initWithFrame:CGRectMake(10,20,sw-20,sh-20)];
 [postv addSubview:quotev];
 quotev.text=quote;
 for(int i=16;i<270;i++){
  quotev.font=sf(i);
  if(quotev.contentSize.height>sh-20){quotev.font=sf(i-1);break;}
 }
 quotev.textColor=[UIColor blackColor];quotev.backgroundColor=[UIColor clearColor];quotev.editable=NO;
}
できた。

今日は振休だったので平日のみ16時までという普段絶対行けない弥七@中津で醤油ちゃーしゅー麺中盛。長蛇の列を覚悟して文庫2冊持ってったけど4人くらいしか並んでなくて拍子抜け。まあ、美味しいけど並ぶほどかと言われれば微妙かな。

2012年5月5日土曜日

LONG LONG TIME AGO

とりあえずlimit近くまでpostを表示させたらJSONをおかわりするロジックを入れた。これでとりあえず体裁は整った。postの重複とかを除けば傍目にはまとも?なtumblrクライアントの振る舞いはする。あとは重複やoffset上限250問題回避のためにidを取り扱おうにもtumblrのidの桁数が多すぎてlongでは扱えないからちょっと調べたらlong longなる型があるのね。これでいけそう。text,link,chat,audio,videoの扱いも決めれば、必要最低限は完成するな。
今日の昼はマッチョ@千日前で並野菜マシマシちょいカラ。初のマシマシ。死ぬかと思った。

2012年5月3日木曜日

uiwebview縮小限界値、非同期のエラー処理 など

明日から5連休!xcodeで遊ぶぞー。
とりあえず、gifを包んだUIWebViewはrectの4値を全部設定することで対応。
でもある一定の縮小率を超えるとコンテンツはそれ以上小さくならないみたい。(rectは普通に変形される)
setScalesPageToFitとは別のプロパティとかあるんかなー。
ただかなり小さくならないと影響ないのでとりあえずこれで進める。
ImageIOは調べてもgifの生成の記事がヒットするけど単にanimatedなgifを再生するだけの記事はどこにもない。
ヘッダ情報からアニメーションばらして再生成とか正気の沙汰じゃないしなー。
あと、UIWebViewの非同期通信は200のステータスが帰ってこなくてもエラー扱いにならないみたいで、自前で処理が必要みたいなので足してみた。

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
 if([((NSHTTPURLResponse *)response) statusCode]!=200){
  data=[[NSMutableData alloc]initWithData:UIImagePNGRepresentation([UIImage imageNamed:@"notfound"])];
  [self makeImage:data];
  [self abort];
 }
 else [data setLength:0];
}

ひとまずこれで動いてるみたい。

昨日は玉造の角力でとんこつ。独特なスープで最初は ん? って感じやけど最後の方はすべて飲み干した。うまい。次はコクしょうゆいってみる。

2012年5月1日火曜日

UIWebViewのリサイズ

gifを包んだUIWebView *gifvをUIImageView *ivにaddSubViewしてivのframeを変形してもgifvが合わせてリサイズされない。setAutoresizingMask設定しても中身はリサイズされてるけど元のrectの大きさはそのままのため余白が空く。ivの変形率からgifの最終的なframe計算してsetするしか無いのかな。なんか気持ち悪い。
昨日の昼は4月最後のラーメンを千林大宮のそらの星で。家系?うーん、、、濃い。やっぱり高井田系が一番すきかな。