iOS Objective-Cでアニメーション
ページ遷移で発火させるならviewDidAppearで記述したほうが良い
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; // trigger animation }
animateWithDurationを使う
開始
[UIView animateWithDuration:2.0f delay:0.5f options:UIViewAnimationOptionCurveEaseInOut animations:^ { _view.frame = CGRectMake(0, 0, 400, 400); } completion:^(BOOL f) { //animation completed }];
停止
[UIView setAnimationBeginsFromCurrentState:YES]; [UIView animateWithDuration:0.001 animations:^{ _view.alpha = 1.0; }];
animateWithDurationを使う
開始
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform"]; anim.fromValue = @[@0.2,@0.2,@0.2]; anim.toValue = @[@2,@2,@2]; anim.valueFunction = [CAValueFunction functionWithName:kCAValueFunctionScale]; anim.duration = 2; anim.repeatCount = HUGE_VALF; [_view.layer addAnimation:anim forKey:nil];
停止
[_view.layer removeAllAnimations];
UIImageViewを使う
開始
const UIImage *im1 = [UIImage imageNamed:@"Australia.png"]; const UIImage *im2 = [UIImage imageNamed:@"Canada.png"]; NSArray *ims = @[im1, im2]; _view.animationImages = ims; _view.animationDuration = 1.5; [_view startAnimating];
停止
[_view stopAnimating];
a
niconicoの新検索βのサジェストAPI
niconicoの検索が新しくなったようなので調べた。
サジェストAPIと新しい検索APIが追加された模様。
検索APIの方はWebSocketも使われていたが、WebSocketで返しているのは"関連タグ"と"検索結果のヒット数"だけで動画の情報などは普通にHTTPで返しているっぽい?(私の調べ方が悪いのかもしれない)
というかサジェストの方でWebSocket使うべきなのでは。
今回はとりあえずサジェストAPIだけ解析結果を。
リクエスト
URL http://sug.search.nicovideo.jp/suggestion/complete *1
メソッド POST
POSTデータ 任意の文字列
レスポンス
形式 JSON
要素 candidates - サジェスト候補の文字列の配列
例
リクエスト
POST /suggestion/complete HTTP/1.1 Host: sug.search.nicovideo.jp Content-Length: 4 voca
レスポンス
{ "candidates": [ "vocajazz", "vocal", "vocalist", "vocaloid", "vocaloid-cdデモ", "vocaloid-pv", "vocaloid2", "vocaloid3", "vocaloid3d化計画", "vocaloid3発売記念コンテスト" ] }
Gsonはjsonとクラスの要素が違っても例外を吐かない
GsonはGoogle製のJava向けjsonパーサーライブラリ。
http://code.google.com/p/google-gson/
Gsonはパースするjsonがjsonの文法的に間違っている場合にのみJsonSyntaxExceptionを吐くらしい。
そっちのほうが都合がいいことが多いし自分が知らなかっただけなんだが、気付かずハマった。
例えば以下のコードは例外を吐かない。
public static class Data{ public String id; public String name; public String hoge; public String huga; } public static void main(String[] args) { String json = "{\"status\":\"error\"}"; Gson gson = new Gson(); Data data = gson.fromJson(json, Data.class); }
fromJsonがnullを返すことはないので、実際に任意のクラスの要素にパースできたかどうか知るには要素がnullかどうか調べればいい。
String json = "{\"status\":\"error\"}"; Gson gson = new Gson(); Data data = gson.fromJson(json, Data.class); if(data.id == null){ //fail }
PSPLinkで拡張メモリを使ったアプリをデバッグする方法
PSPLinkはそのままでは拡張メモリを使った(PSP_LARGE_MEMORY = 1指定した)アプリのデバッグできない。
Toolchain付属のPSPLinkはそもそも古いので最新版を落とす。
https://github.com/pspdev/psplinkusb
これをコンパイルすれば拡張メモリ使用アプリをPSPLinkから実行できるが、psp-gdbでcannot access ~系のエラーを吐くのでハードコーディングされたメモリの領域を変更する。
usbgdb/main.c:128
if((addr >= 0x08800000) && (addr < 0x0A000000)) →if((addr >= 0x08800000) && (addr < 0x0C000000))
usbgdb/main.c:163
if((addr >= 0x08800000) && (addr < 0x0A000000)) →if((addr >= 0x08800000) && (addr < 0x0C000000))
これでusbgdbを再コンパイルして出来上がったusbgdb.prxと差し替えればOK。
Hello World.
技術的なことはここに書く。