自分でも簡単なサンプルを作ってみて確認しましたが、おっしゃる通り株価の様に画面以上に広げることは
無理でした。
最大で表示できるのはせいぜい使用した端末の画面サイズくらいまでで、
それ以降は表示されませんでした。
しかし、画面サイズほぼいっぱいまでは以下のサイトの通りで出来ましたので。参考までにスクショとコードを載せておきます。
Today Extensionの高さの最大値の計算式
swift
1import UIKit
2import NotificationCenter
3
4class TodayViewController: UIViewController, NCWidgetProviding {
5
6 override func viewDidLoad() {
7 super.viewDidLoad()
8 self.preferredContentSize = CGSizeMake(0, 200)
9 }
10
11 func widgetPerformUpdateWithCompletionHandler(completionHandler: ((NCUpdateResult) -> Void)) {
12 completionHandler(NCUpdateResult.NewData)
13 }
14
15
16 @IBAction func tapButton(sender: UIButton) {
17 // ボタン押下時
18 self.preferredContentSize = CGSizeMake(0, UIScreen.mainScreen().bounds.size.height - 126);
19 }
20
21 // Data Array
22 private lazy var dataArray: [String] = { [unowned self] in
23 var dataArray: [String] = []
24 for i in 0..<20 {
25 dataArray.append("Table No : \(i)")
26 }
27 return dataArray
28 }()
29
30 // MARK: - TableView Delegate & DataSource
31 // Row Count
32 func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
33 return dataArray.count
34 }
35
36 // Row Height
37 func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
38 return 44
39 }
40
41 // Generate Cell
42 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
43 let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
44 cell.textLabel?.textColor = UIColor.redColor()
45 cell.textLabel?.text = dataArray[indexPath.row]
46 return cell
47 }
48}
表示時
ボタン押下時
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/03/23 15:34
2016/03/24 16:19