[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];
関連記事
-
-
TableView関連で苦労
iPhoneアプリ開発をやっていると数日に一度何らかの問題にぶつかって、しばらくはまる。本を読んだり
-
-
[iOS] アプリ名にiPadと入れてRejectされた話
新作 iPad アプリを App Store に Submit したところ、Reject されたので
-
-
Linking 対応デバイス tomoru
この前 Makuake で出資しそこねた Tomoru が Amazon で ¥ 1,069 + ¥
-
-
iOS6 の Guided Access (Single App Mode) が便利そう
昨日のWWDC 2012 キーノートではiOS6の紹介がありいろいろと新機能の説明があったけ
-
-
これは便利 iPhoneプログラミングUIKit詳解リファレンス
Amazonでの評判も良いし、書店で立ち読みしていくつか有用な情報を見つけたので、iPhoneプログ
-
-
AWS IoTを利用してクラウド連携機能を追加してみた
GWに自宅待機でまとまった時間が確保できたので、AWS IoT を利用してMQTTを使った
-
-
[iOS SDK] iPhone 6 Plus を Xcode に追加する
なぜか毎回新規デバイス追加に少し手間取ってしまう。 今回は先日購入した iPhone 6 Plus
-
-
[iPhone5] ステータスバーの謎の○(丸)表示
iPhone5使い始めて2日目、自宅でもLTE表示が出ていたのになぜかある時から○表示になってしまっ
-
-
[iOS開発本] 詳解 iOS5 プログラミング の感想
書店で見かけて久しぶりに即買いしたiOS開発本。 今日ようやくざっと読めて、予想以上におもしろかった
-
-
3/8(木)深夜はiPad3の発表?
3/7(水)(日本時間3/8(木)深夜) にAppleのプレスイベントがあり、iPad3 が発表