###前提・実現したいこと
OnboardでiOSアプリのウォークスルー画面を簡単に実装 - Qiitaを参考に起動時一度だけ表示するウォークスルーを作ろうと試みました。
実現したいこととしては、本記事の3つ目の画面(content3)のボタンをクリックしアラートが表示された際に、MainVC(最初のVC)に遷移させることです。
「"return true" で戻ると思ってたのですがうまくできず、Segueで紐づけているわけでも無いので飛ばすこともできないし…。」
と正しい書き方がわかりません。
実際のところどうなっているのでしょうか?
この問題に関して教えていただければ幸いです。
よろしくお願いいたします。
###該当のソースコード
swift
1import UIKit 2import Onboard 3 4@UIApplicationMain 5class AppDelegate: UIResponder, UIApplicationDelegate { 6 7 var window: UIWindow? 8 9 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 10 11 if true { 12 let content1 = OnboardingContentViewController( 13 title: "Title1", 14 body: "Body1", 15 image: nil, 16 buttonText: "", 17 action: nil 18 ) 19 let content2 = OnboardingContentViewController( 20 title: "Title2", 21 body: "Body2", 22 image: nil, 23 buttonText: "", 24 action: nil 25 ) 26 let content3 = OnboardingContentViewController( 27 title: "Title3", 28 body: "Body3", 29 image: nil, 30 buttonText: "ログイン", 31 action: { 32 let alert = UIAlertController( 33 title: "ログイン", 34 message: "ログインしました", 35 preferredStyle: .alert 36 ) 37 let ok = UIAlertAction( 38 title: "OK", 39 style: .default, 40 handler: 41 { 42 (action:UIAlertAction!) -> Void in 43 // ここに何か処理を書くのか・・・? 44 }) 45 alert.addAction(ok) 46 application.keyWindow?.rootViewController?.present(alert, animated: true, completion: nil) 47 } 48 ) 49 50 let bgImageURL = NSURL(string: "https://www.pakutaso.com/shared/img/thumb/KAZ_hugyftdrftyg_TP_V.jpg")! 51 let bgImage = UIImage(data: NSData(contentsOf: bgImageURL as URL)! as Data) 52 let vc = OnboardingViewController( 53 backgroundImage: bgImage, 54 contents: [content1, content2, content3] 55 ) 56 vc?.allowSkipping = true 57 vc?.skipHandler = { 58 print("skip") 59 } 60 61 window?.rootViewController = vc 62 63 return true 64 } 65 66 return true 67 } 68 69} 70
###試したこと
// ここに何か処理を書くのか・・・?
の地点まで処理が来ていることを確認。
そこに、return true を記載してみたがうまくいかず。
###補足情報(言語/FW/ツール等のバージョンなど)
swift 4.0 / Xcode 9.2 を使用しています。
あなたの回答
tips
プレビュー