我已经注意到,在使用(Swift 4.0)的IOS X代码中,我至少可以通过以下两种方式要求视图的高度V:
Find.Execute
和...
Sub testRangesInArrays()
Dim rngIAM_Code() As Range
Dim rngIAM_Title() As Range
rngIAM_Code = findRanges("You", ActiveDocument)
rngIAM_Title = findRanges("change", ActiveDocument)
End Sub
Function findRanges(keyword As String, doc As Word.Document) As Range()
Dim foundRanges() As Range, rngSearch As Range
Dim i As Integer, foundCount As Integer
i = 0
foundCount = 0
ReDim foundRanges(0)
Set rngSearch = doc.content
Do While rngSearch.Find.Execute(findText:=keyword, MatchWholeWord:=True, _
Forward:=True, wrap:=wdFindStop) = True
Set foundRanges(i) = rngSearch.Duplicate
ReDim Preserve foundRanges(UBound(foundRanges) + 1)
i = i + 1
rngSearch.Collapse Direction:=wdCollapseEnd
Loop
findRanges = foundRanges
End Function
这两者之间有什么实际区别吗?
我做了选项单击操作(给出了不同的定义,但是没有解释任何实际的区别或原因)和stackoverflow ...但是在这里,关于stackoverflow,所有结果都在讨论中边界和框架之间的区别...这不是我要问的。
答案 0 :(得分:6)
V.bounds.height
只是一个GET属性。您无法为此属性设置值。
示例:
self.view.bounds.height = 5
此错误消息导致...
无法分配给属性:“ height”是一个只能获取的属性
如果要为此属性分配一个值,则可以编写...
self.view.bounds.size.height = 5
因此您可以为该对象设置值。看看here.
答案 1 :(得分:1)
差别很小。 view.bounds.height
是一种快捷方式。您无法编辑它:
view.bounds.height = 150
无效,但view.bounds.size.height = 150
可用。
答案 2 :(得分:1)
实际上V.bounds.size.height
,高度都具有get-set属性,而在V.bounds.height
中, height 只是getter属性,它总是返回您是矩形的高度。
对于吸气剂而言,两者是相同的。
答案 3 :(得分:1)
In addition to the fact that view.bounds.height
is readonly, there is another difference: if you have negative width/height, view.bounds.height
will return you the normalized value (the positive one), while view.bounds.size.height
will return the real value. These getters are the equivalent of the CGRectGetWidth()
CGRectGetHeight()
from Obj-C. All these getters from CGRect
struct (widht
, height
, minX
, minY
...) are returning the normalized values of the CGRect
's dimensions and they are recommended in case you want to use them in frame computations.