質問編集履歴
2
appdelegateのソースの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -113,3 +113,143 @@
|
|
113
113
|
}
|
114
114
|
|
115
115
|
}
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
以下appdelegate
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
lass AppDelegate: UIResponder, UIApplicationDelegate{
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
//UISplitiViewContorollerの初期設定
|
136
|
+
|
137
|
+
//それぞれのviewのインスタンスを作成
|
138
|
+
|
139
|
+
var window: UIWindow?
|
140
|
+
|
141
|
+
var masterViewController = MasterViewController()
|
142
|
+
|
143
|
+
var masterNavigationController = UINavigationController()
|
144
|
+
|
145
|
+
var detailViewController = DetailViewController()
|
146
|
+
|
147
|
+
var detailNavigationController = UINavigationController()
|
148
|
+
|
149
|
+
var splitViewController = UISplitViewController()
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
func splitVC() -> UISplitViewController{
|
154
|
+
|
155
|
+
//viewにnavigationの追加とタイトルの設定
|
156
|
+
|
157
|
+
//master
|
158
|
+
|
159
|
+
masterViewController.title = "Master"
|
160
|
+
|
161
|
+
masterNavigationController.addChildViewController(masterViewController)
|
162
|
+
|
163
|
+
//detail
|
164
|
+
|
165
|
+
detailViewController.title = "Detail"
|
166
|
+
|
167
|
+
detailNavigationController.addChildViewController(detailViewController)
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
//上記のnavigationをsplitViewを使い結合
|
172
|
+
|
173
|
+
splitViewController.addChildViewController(masterNavigationController)
|
174
|
+
|
175
|
+
splitViewController.addChildViewController(detailNavigationController)
|
176
|
+
|
177
|
+
//splitViewControllerのdelegateをmasterViewControllerに委託
|
178
|
+
|
179
|
+
splitViewController.delegate = detailViewController
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
return splitViewController
|
184
|
+
|
185
|
+
}
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
|
192
|
+
|
193
|
+
// Override point for customization after application launch.
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
//windowのrootをsplitViewControllerに設定
|
198
|
+
|
199
|
+
self.window?.rootViewController = self.splitVC()
|
200
|
+
|
201
|
+
self.window?.makeKeyAndVisible()
|
202
|
+
|
203
|
+
return true
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
func applicationWillResignActive(application: UIApplication) {
|
210
|
+
|
211
|
+
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
212
|
+
|
213
|
+
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
func applicationDidEnterBackground(application: UIApplication) {
|
220
|
+
|
221
|
+
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
222
|
+
|
223
|
+
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
func applicationWillEnterForeground(application: UIApplication) {
|
230
|
+
|
231
|
+
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
|
232
|
+
|
233
|
+
}
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
func applicationDidBecomeActive(application: UIApplication) {
|
238
|
+
|
239
|
+
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
240
|
+
|
241
|
+
}
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
func applicationWillTerminate(application: UIApplication) {
|
246
|
+
|
247
|
+
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
}
|
1
detailViewContorollerの内容について
test
CHANGED
File without changes
|
test
CHANGED
@@ -19,3 +19,97 @@
|
|
19
19
|
このエラーコードはどういった意味なのでしょうか?
|
20
20
|
|
21
21
|
回答の方、何卒よろしくお願いいたします
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
detailのなかみは下記になります
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
import UIKit
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
class DetailViewController: UISplitViewController ,UISplitViewControllerDelegate {
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
override func viewDidLoad() {
|
42
|
+
|
43
|
+
super.viewDidLoad()
|
44
|
+
|
45
|
+
self.view.backgroundColor = UIColor.whiteColor()
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
// ボタンの定義をおこなう.
|
50
|
+
|
51
|
+
let myButton = UIButton(frame: CGRectMake(0,0,100,50))
|
52
|
+
|
53
|
+
myButton.backgroundColor = UIColor.orangeColor()
|
54
|
+
|
55
|
+
myButton.layer.masksToBounds = true
|
56
|
+
|
57
|
+
myButton.setTitle("ボタン", forState: .Normal)
|
58
|
+
|
59
|
+
myButton.layer.cornerRadius = 20.0
|
60
|
+
|
61
|
+
myButton.layer.position = CGPoint(x: self.view.bounds.width/2, y:200)
|
62
|
+
|
63
|
+
myButton.addTarget(self, action: "onClickMyButton:", forControlEvents: .TouchUpInside)
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
// ボタンをViewに追加する.
|
68
|
+
|
69
|
+
self.view.addSubview(myButton)
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
// Do any additional setup after loading the view.
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
override func didReceiveMemoryWarning() {
|
80
|
+
|
81
|
+
super.didReceiveMemoryWarning()
|
82
|
+
|
83
|
+
// Dispose of any resources that can be recreated.
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
func onClickMyButton(sender: UIButton){
|
90
|
+
|
91
|
+
println("ボタン押下")
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
func splitViewController(svc: UISplitViewController, willHideViewController aViewController: UIViewController, withBarButtonItem barButtonItem: UIBarButtonItem, forPopoverController pc: UIPopoverController) {
|
100
|
+
|
101
|
+
//splitviewのボタンアイテムの設定
|
102
|
+
|
103
|
+
barButtonItem.title = "メニュー"
|
104
|
+
|
105
|
+
self.navigationItem.leftBarButtonItem = barButtonItem
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
func splitViewController(svc: UISplitViewController, willShowViewController aViewController: UIViewController, invalidatingBarButtonItem barButtonItem: UIBarButtonItem) {
|
110
|
+
|
111
|
+
self.navigationItem.leftBarButtonItem = nil
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
}
|