[iOS SDK] QuickDialog を使ってみた

公開日: : 最終更新日:2013/09/09 iPad, iPhone

[IOS] iOS オープンソースライブラリ徹底活用 菊田剛著 秀和システム | DevCafeJp で紹介されていた、QuickDialog – ESCOZ Inc を利用してみた。

これを利用すると設定画面作成作業がかなり楽になるのでとても助かる。
ドキュメントはあまりないので、サンプルプログラムを動かしてみて理解していくのが良さそう。
QuickDialog は ARC をサポートしている。

まだ検索してみてもあまりサンプルコードが見つからないので、参考までに今回使ったコードを切り出してみた。
これはTableViewから1つを選択するタイプのダイアログ。

Quick1使い方がこれで正しいかは不明だが、動いてはいる。

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:^{
//
}];

こちらはラベルを複数表示するタイプのダイアログ。

Quick2

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];

関連記事

安くなったPFUのSnapLiteを買ってみた

昔からほしかったが高くて手が出なかったPFUのSnapLiteが2018年3月に販売終了になったらし

記事を読む

ITMS-90175 Legacy Language Designator

自分は自作アプリの非常に古いプロジェクトをいまだにメンテすることがあるので、ITMS-90

記事を読む

[iOS SDK] iPad 専用アプリをiPhoneでも使えるようにする

 iPad 初代やiPad2の頃は、iPhoneとiPadの画面サイズがかなり異なり、また

記事を読む

ついにうちにもジェットブラックが来た。

予約から1ヶ月、ようやくうちにもiPhone 7 Plus ジェットブラックがきた。(2016/10

記事を読む

US Unlocked にてiPad 購入、無事入手

日本の発売まで待つか結構悩んだけれども、なるべく早く自作アプリの動作確認をしておきたいということもあ

記事を読む

no image

[iPhone開発本] iPhoneではじめるOpenGL ESプログラミング

2010/07/13(火)発売。昨日書店で立ち読みしてみたら良さそうな本だった。 パンカクの本も良か

記事を読む

no image

最近読んだ本 iPhoneデジカメプログラミング

カメラアプリを作る予定はなかったので2011年3月に発売されてからしばらく様子を見ていたが、そろそろ

記事を読む

no image

iPhoneアプリ 「リズムくん」 Ver.1.1 アップデート

リズムくん Ver.1.0ではまずは8分音符までの問題でリリースしてみましたが、やはりより難しい問題

記事を読む

no image

[IOS] iOS オープンソースライブラリ徹底活用 菊田剛著 秀和システム

ふらっと家の近くの書店に寄ったところたまたま発見した本。 最近発売されたようだ。 21章で69

記事を読む

EverLearn 1.7.5 を公開しました

英単語学習アプリ EverLearn 1.7.5 を公開しました。変更点エビングハウスの忘却曲線を参

記事を読む

Message

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Ember Mug 2のACアダプタをUSB Type-Cに変えてみた

冬になると活躍する Ember Mug 2 の充電器は付属のACアダ

Wi-Fi6Eルータ TP-Link AXE5400購入

Wi-Fi6E を試してみたくなり、TP-Link AXE5

児童手当 認定請求書申請 2024 「請求者が養育をする18歳に達する日以降の最初の3月31日までの子の数」とは?

2024年に受給していない人には手紙が届くらしい。 電子申請も

Vision Proアプリ開発本 8/24、8/26に発売

Vision Proアプリ開発入門 P400が 8/24 に発売、V

Developer Strap が日本でも購入可能に

USアカウントでしか購入できなかった Vision Pro 用 De

→もっと見る

  • 2013年2月
     123
    45678910
    11121314151617
    18192021222324
    25262728  
PAGE TOP ↑