Skip to content

Commit

Permalink
Merge pull request tidev#5577 from vishalduggal/timob-16793
Browse files Browse the repository at this point in the history
[TIMOB-16793] Subview index is not always reliable
  • Loading branch information
srahim committed Apr 3, 2014
2 parents 658b1fc + f222dcd commit 373e295
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion iphone/Classes/TiViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -2119,12 +2119,15 @@ -(void)insertSubview:(UIView *)childView forProxy:(TiViewProxy *)childProxy
return;
}

UIView* lastView = nil;

if (![self optimizeSubviewInsertion]) {
NSArray* subViews = [[ourView subviews] retain];

for (UIView* subview in subViews) {
if (![subview isKindOfClass:[TiUIView class]]) {
result++;
lastView = subview;
}
}
[subViews release];
Expand All @@ -2139,10 +2142,17 @@ -(void)insertSubview:(UIView *)childView forProxy:(TiViewProxy *)childProxy
return (first > second) ? NSOrderedDescending : ( first < second ? NSOrderedAscending : NSOrderedSame );
}];


for (TiViewProxy * thisChildProxy in sortedArray) {
if ([thisChildProxy viewInitialized] ) {
[ourView insertSubview:[thisChildProxy view] atIndex:result];
UIView* newView = [thisChildProxy view];
if (lastView == nil) {
[ourView insertSubview:newView atIndex:result];
} else {
[ourView insertSubview:newView aboveSubview:lastView];
}
result ++;
lastView = newView;
}
}
pthread_rwlock_unlock(&childrenLock);
Expand Down

0 comments on commit 373e295

Please sign in to comment.