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

関連記事

no image

[iOS SDK] 物書堂の辞書アプリと連携してみた

物書堂は使い勝手のよい辞書アプリをたくさんリリースしている会社だ。 今作っている英単語学習アプリで

記事を読む

no image

iPad用ペン AluPen を買ってみた。

年末に注文したAluPenをようやく入手。品薄で1ヶ月かかってしまった。Amazonで2404円。紹

記事を読む

no image

[iOS] iOS6 から起動時に一度 Portraitになる挙動が変更された模様

iOS6 からは画面の回転関係の仕様が整理されたのか、いろいろと変更が入っている。 まず - (B

記事を読む

dyld`__abort_with_payload:でクラッシュ WatchKitApp on Xcode11.1

Xcode 11.0 や Xcode11.1で以前はビルドして実行できていたWatchKi

記事を読む

no image

[iPhone SDK] UILabel からポップアップメニューを表示してみる

今作っているアプリに UILabel を複数置いた画面があるが、その UILabelたちは編集

記事を読む

no image

[iPhone SDK] ツールバー(UIToolBar) に矢印ボタンを入れる

iPhone OS 3.0から、UIBarButtonItem たちを NSArray に入れて、U

記事を読む

no image

[iPhone SDK] アプリケーションのローカライズ

iPhoneアプリを作っていて、一通り作り終わったら最後にやる作業の一つとして、ローカライズがある。

記事を読む

Apple Event 2016秋 See you on the 7th

2016秋のApple Eventは 2016/09/07(日本時間 9/8 2:00)に行われた。

記事を読む

Apple Event Apple Watch 3/10 2AM JST

Apple Watch に関するイベントが3/10(火)2:00AM JSTに行われるら

記事を読む

no image

iPhone開発本 iPhone Cool Projects

iPhone Games Projectsに続いて、iPhone Cool Projects も買っ

記事を読む

Message

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

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください

ポモドーロテクニック用物理タイマーならTime Timer

会社ではなかなか自由に時間を使えないが、家で読書や作業をする

DELL 32インチディスプレイ U3223QE 購入

Dell U3223QE は解像度 3840x216

WWDC 2023 Vision Pro発表

2023/6/5 (日本時間 2023/06/06 2AM)のWWD

M1 MacBook Air を Venturaにアップデートする

M1 MacBook Air を macOS Montere

iOS16でaurioTouch の inBufferFramesが1になる

https://developer.apple.com/librar

→もっと見る

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