mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
Merge pull request #1093 from NativeScript/switch
Fixed #986: [iOS] The switch widget does not show up on the page.
This commit is contained in:
@ -1,6 +1,8 @@
|
|||||||
import common = require("./switch-common");
|
import common = require("./switch-common");
|
||||||
import dependencyObservable = require("ui/core/dependency-observable");
|
import dependencyObservable = require("ui/core/dependency-observable");
|
||||||
import proxy = require("ui/core/proxy");
|
import proxy = require("ui/core/proxy");
|
||||||
|
import utils = require("utils/utils");
|
||||||
|
import viewModule = require("ui/core/view");
|
||||||
|
|
||||||
function onCheckedPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
function onCheckedPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||||
var swtch = <Switch>data.object;
|
var swtch = <Switch>data.object;
|
||||||
@ -49,4 +51,14 @@ export class Switch extends common.Switch {
|
|||||||
get ios(): UISwitch {
|
get ios(): UISwitch {
|
||||||
return this._ios;
|
return this._ios;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
|
||||||
|
// It can't be anything different from 51x31
|
||||||
|
let nativeSize = this._nativeView.sizeThatFits(CGSizeMake(0, 0));
|
||||||
|
this.width = nativeSize.width;
|
||||||
|
this.height = nativeSize.height;
|
||||||
|
let widthAndState = utils.layout.makeMeasureSpec(nativeSize.width, utils.layout.EXACTLY);
|
||||||
|
let heightAndState = utils.layout.makeMeasureSpec(nativeSize.height, utils.layout.EXACTLY);
|
||||||
|
this.setMeasuredDimension(widthAndState, heightAndState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user