Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[TIMOB-8547] iOS: switch change event gets fired when adding to a vie…

…w or window
  • Loading branch information...
commit 127608733cf64a44f43a87853d17c1e172174b45 1 parent b450994
@mstepanov authored
View
5 iphone/Classes/TiUISwitch.m
@@ -53,11 +53,14 @@ -(void)setValue_:(id)value
BOOL newValue = [TiUtils boolValue:value];
BOOL animated = !reproxying;
UISwitch * ourSwitch = [self switchView];
+ if ([ourSwitch isOn] == newValue) {
+ return;
+ }
[ourSwitch setOn:newValue animated:animated];
// Don't rely on switchChanged: - isOn can report erroneous values immediately after the value is changed!
// This only seems to happen in 4.2+ - could be an Apple bug.
- if (reproxying==NO && [self.proxy _hasListeners:@"change"])
+ if ((reproxying == NO) && configurationSet && [self.proxy _hasListeners:@"change"])
{
[self.proxy fireEvent:@"change" withObject:[NSDictionary dictionaryWithObject:value forKey:@"value"]];
}
View
3  iphone/Classes/TiUIView.h
@@ -29,6 +29,9 @@ void ModifyScrollViewForKeyboardHeightAndContentHeightWithResponderRect(UIScroll
@interface TiUIView : UIView<TiProxyDelegate,LayoutAutosizing>
{
+@protected
+ BOOL configurationSet;
+
@private
TiProxy *proxy;
TiAnimation *animation;
View
1  iphone/Classes/TiUIView.m
@@ -272,6 +272,7 @@ -(void)initializeState
-(void)configurationSet
{
// can be used to trigger things after all properties are set
+ configurationSet = YES;
}
-(void)setProxy:(TiProxy *)p
Please sign in to comment.
Something went wrong with that request. Please try again.