Class: MIM::MotionBrowser

Inherits:
UIView
  • Object
show all
Defined in:
lib/uikit/motion_browser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#webviewObject (readonly)

Returns the value of attribute webview.



3
4
5
# File 'lib/uikit/motion_browser.rb', line 3

def webview
  @webview
end

Instance Method Details

#initObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/uikit/motion_browser.rb', line 5

def init
  super

  setBackgroundColor UIColor.whiteColor

  addSubview(@webview = UIWebView.new)
  addSubview(@toolbar = MotionBrowserToolbar.new)
  @delegate = @toolbar.delegate = MotionBrowserToolbarDelegate.new(@webview)

  @webview.translatesAutoresizingMaskIntoConstraints = false
  @toolbar.translatesAutoresizingMaskIntoConstraints = false

  attributes = []
  attributes << NSLayoutConstraint.constraintWithItem(
    @webview,
    attribute: NSLayoutAttributeTop,
    relatedBy: NSLayoutRelationEqual,
    toItem: self,
    attribute: NSLayoutAttributeTop,
    multiplier: 1,
    constant: 0
  )

  attributes << NSLayoutConstraint.constraintWithItem(
    @webview,
    attribute: NSLayoutAttributeBottom,
    relatedBy: NSLayoutRelationEqual,
    toItem: self,
    attribute: NSLayoutAttributeBottom,
    multiplier: 1,
    constant: 0
  )

  attributes << NSLayoutConstraint.constraintWithItem(
    @webview,
    attribute: NSLayoutAttributeLeft,
    relatedBy: NSLayoutRelationEqual,
    toItem: self,
    attribute: NSLayoutAttributeLeft,
    multiplier: 1,
    constant: 0
  )

  attributes << NSLayoutConstraint.constraintWithItem(
    @webview,
    attribute: NSLayoutAttributeRight,
    relatedBy: NSLayoutRelationEqual,
    toItem: self,
    attribute: NSLayoutAttributeRight,
    multiplier: 1,
    constant: 0
  )

  attributes << NSLayoutConstraint.constraintWithItem(
    @toolbar,
    attribute: NSLayoutAttributeHeight,
    relatedBy: NSLayoutRelationEqual,
    toItem: nil,
    attribute: NSLayoutAttributeNotAnAttribute,
    multiplier: 1,
    constant: 50
  )

  attributes << NSLayoutConstraint.constraintWithItem(
    @toolbar,
    attribute: NSLayoutAttributeBottom,
    relatedBy: NSLayoutRelationEqual,
    toItem: self,
    attribute: NSLayoutAttributeBottom,
    multiplier: 1,
    constant: 0
  )

  attributes << NSLayoutConstraint.constraintWithItem(
    @toolbar,
    attribute: NSLayoutAttributeLeft,
    relatedBy: NSLayoutRelationEqual,
    toItem: self,
    attribute: NSLayoutAttributeLeft,
    multiplier: 1,
    constant: 0
  )

  attributes << NSLayoutConstraint.constraintWithItem(
    @toolbar,
    attribute: NSLayoutAttributeRight,
    relatedBy: NSLayoutRelationEqual,
    toItem: self,
    attribute: NSLayoutAttributeRight,
    multiplier: 1,
    constant: 0
  )
  addConstraints(attributes)

  self
end

#load(url) ⇒ Object



102
103
104
105
106
107
108
109
# File 'lib/uikit/motion_browser.rb', line 102

def load(url)
  unless url.is_a? NSURL
    url = NSURL.URLWithString(url)
  end

  request = NSURLRequest.requestWithURL(url)
  @webview.loadRequest(request)
end