[iOS SDK] QuickDialog を使ってみた
[IOS] iOS オープンソースライブラリ徹底活用 菊田剛著 秀和システム | DevCafeJp で紹介されていた、QuickDialog – ESCOZ Inc を利用してみた。
これを利用すると設定画面作成作業がかなり楽になるのでとても助かる。
ドキュメントはあまりないので、サンプルプログラムを動かしてみて理解していくのが良さそう。
QuickDialog は ARC をサポートしている。
まだ検索してみてもあまりサンプルコードが見つからないので、参考までに今回使ったコードを切り出してみた。
これはTableViewから1つを選択するタイプのダイアログ。
使い方がこれで正しいかは不明だが、動いてはいる。
QRootElement* root = [[QRootElement alloc] init]; root.grouped = YES; root.title = NSLocalizedString(@"Separate String", @"Separate String"); QSelectSection *simpleSelectSection = [[QSelectSection alloc] initWithItems:nameArray selectedIndexes:nil title:NSLocalizedString(@"Select a separate string", @"Select a separate string")]; simpleSelectSection.onSelected = ^{ NSNumber *selected = [simpleSelectSection.selectedIndexes objectAtIndex:0]; }; [root addSection:simpleSelectSection]; QSection *btnSection = [[QSection alloc]initWithTitle:nil]; [root addSection:btnSection]; QButtonElement *okBtn = [[QButtonElement alloc]initWithTitle:@"OK"]; okBtn.onSelected = ^{ [self dismissViewControllerAnimated:YES completion:^{ [self.tableView reloadData]; }]; }; [btnSection addElement:okBtn]; QuickDialogController *qc = [[QuickDialogController alloc]initWithRoot:root]; [self presentViewController:qc animated:YES completion:^{ // }];
こちらはラベルを複数表示するタイプのダイアログ。
QRootElement* root = [[QRootElement alloc] init]; root.grouped = YES; root.title = nil; QSection* detailsSection = [[QSection alloc] initWithTitle:NSLocalizedString(@"About", @"About")]; [root addSection:detailsSection]; NSString *str1 = NSLocalizedString(@"Support Site", @"Supoprt Site"); NSString *str2 = NSLocalizedString(@"Twitter", @"Twitter"); QLabelElement *label1 = [[QLabelElement alloc]initWithTitle:str1 Value:nil]; label1.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; label1.onSelected = ^{ NSString *str = NSLocalizedString(@"https://tokentoken.com/blog/support-e/", @"SupportSiteURL"); NSURL *target = [[NSURL alloc] initWithString:str]; [[UIApplication sharedApplication] openURL:target]; }; [detailsSection addElement:label1]; QLabelElement *label2 = [[QLabelElement alloc]initWithTitle:str2 Value:nil]; label2.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; label2.onSelected = ^{ NSString *str = NSLocalizedString(@"http://www.twitter.com/onpuchan_app/", @"TwitterURL"); NSURL *target = [[NSURL alloc] initWithString:str]; [[UIApplication sharedApplication] openURL:target]; }; [detailsSection addElement:label2]; QSection *btnSection = [[QSection alloc]initWithTitle:nil]; [root addSection:btnSection]; QButtonElement *okBtn = [[QButtonElement alloc]initWithTitle:@"OK"]; okBtn.onSelected = ^{ [self dismissViewControllerAnimated:YES completion:^{ // }]; }; [btnSection addElement:okBtn]; QuickDialogController *qc = [[QuickDialogController alloc]initWithRoot:root]; [self presentViewController:qc animated:YES completion:^{ // }];
iOS は便利なライブラリがどんどん出てくるので作りたいものに集中できるのはありがたいこと。
追記 2013/09/09
QuickDialog には、QuickDialog内部で使っている便利クラスが存在する。
例えばその中の QWebViewController はリロードボタンや戻る・進むボタンが用意されたViewControllerで、url を渡すだけでWebページを表示してくれる。
ちょっとWebを表示したいだけなので手をかけずに実現したい、という時には便利そう。
QWebViewController *webC = [[QWebViewController alloc]initWithUrl:url]; [self.navigationController pushViewController:webC animated:YES]; [webC release];
関連記事
-
-
UITableViewCell セルの再利用の問題
設定画面に他の自作アプリ情報を加えたりしようと思い、UITableViewController で1
-
-
[iOS] iOSでToast
iOSでAndroidのToast的な、数秒間メッセージを表示して自動的に消える部品を探していたのだ
-
-
iPadアプリ おんぷちゃん が雑誌に紹介されました
いろいろあって、iPhone/iPad アプリのおんぷちゃん がムジカノーヴァ2011年2月号で紹介
-
-
iOS6 の Guided Access (Single App Mode) が便利そう
昨日のWWDC 2012 キーノートではiOS6の紹介がありいろいろと新機能の説明があったけ
-
-
スマートフォン手袋を買ってみた 2011
去年買ったスマートフォン用手袋は石油くさくてかなりつらい思いをしながら使ってましたが、今年もこりず
-
-
Reject履歴 EverLearn 1.7.0
どうやら Apple Watch対応アプリの審査は厳しいらしいので、Rejectされた履歴を書いてみ
-
-
[iOS SDK] NSUserDefaults boolForKey でNOが返ってくるとNOが格納されていたのか値が存在しなかったのかが不明
NSUserDefaults Class Reference にあるとおり、NSUserDefau
-
-
[iOS] INNER JOIN に失敗する
非常に面妖な状況でにわかには信じがたいのだが、iPhone 6 Plus だと問題なく動作する
-
-
林信行氏 iPhoneの衝撃 セミナー 2009/10/07@代々木 に参加してきた
いまさらながら、2009/10/07(水)に行われた、林信行氏 iPhoneの衝撃 セミナーのレポ
-
-
Xcodeの Console出力をクリアするキーバインド
いつも忘れるので、メモとして残しておく。Command(⌘)+ Kその他はこちら。 Menu Com