Skip to content

Instantly share code, notes, and snippets.

@mexelout
Last active March 31, 2017 01:57
Show Gist options
  • Save mexelout/30767668dcd7f0d2e12349963d8acce8 to your computer and use it in GitHub Desktop.
Save mexelout/30767668dcd7f0d2e12349963d8acce8 to your computer and use it in GitHub Desktop.
UIViewControllerの下位互換をしてくれるラッピング関数 ios4 - ios5 もう要らないコードかも?
// view controller wrapping function
/**
* プレゼントビューコントローラーのラッピング関数
* @param me 呼び出すを行うビューコントローラー(基本的にはselfを指定)
* @param vc 呼び出しをされるビューコントローラー
* @param flag アニメーションフラグ
* @param comp 終了後に呼ぶブロック関数
*/
void presentViewController(UIViewController* me, UIViewController* vc, BOOL flag, void* comp) {
// ios 4まではpresentModalViewController
// ios 5以降はpresentViewController
// で動かさなくてはならない
if(iOSVersion < 5) {
[me presentModalViewController:vc animated:flag];
} else {
[me presentViewController:vc animated:flag completion:comp];
}
}
/**
* ディスミスビューコントローラーのラッピング関数
* @param me 呼び出すを行うビューコントローラー(基本的にはselfを指定)
* @param flag アニメーションフラグ
* @param comp 終了後に呼ぶブロック関数
*/
void dismissViewController(UIViewController* me, BOOL flag, void* comp) {
// ios 4まではdismissModalViewController
// ios 5以降はdismissViewController
// で動かさなくてはならない
if(iOSVersion < 5) {
[me dismissModalViewControllerAnimated:YES];
} else {
[me dismissViewControllerAnimated:flag completion:comp];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment