Skip to content

Commit

Permalink
Merge pull request #5953 from vishalduggal/timob-17373
Browse files Browse the repository at this point in the history
[TIMOB-17373] iOS: Disappearing separators on iOS7 and iOS8
  • Loading branch information
srahim committed Aug 7, 2014
2 parents e145a1a + a8bd8f2 commit 57aaa22
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 2 deletions.
1 change: 1 addition & 0 deletions iphone/Classes/TiUIListItem.h
Expand Up @@ -32,6 +32,7 @@ enum {
- (BOOL)canApplyDataItem:(NSDictionary *)otherItem;
- (void)setPosition:(int)position isGrouped:(BOOL)grouped;
- (void)configureCellBackground;
- (void) ensureVisibleSelectorWithTableView:(UITableView*)tableView;
@end

#endif
26 changes: 25 additions & 1 deletion iphone/Classes/TiUIListItem.m
Expand Up @@ -116,7 +116,31 @@ - (void)layoutSubviews
}
}

#pragma mark - Background Support
//TIMOB-17373. Workaround for separators disappearing on iOS7 and above
- (void) ensureVisibleSelectorWithTableView:(UITableView*)tableView
{
if (![TiUtils isIOS7OrGreater] || [self selectedOrHighlighted]) {
return;
}
UITableView* attachedTableView = tableView;
UIView* superView = [self superview];
while (attachedTableView == nil && superView != nil) {
if ([superView isKindOfClass:[UITableView class]]) {
attachedTableView = (UITableView*)superView;
}
superView = [superView superview];
}

if (attachedTableView != nil && attachedTableView.separatorStyle != UITableViewCellSeparatorStyleNone) {
for (UIView *subview in self.contentView.superview.subviews) {
if ([NSStringFromClass(subview.class) hasSuffix:@"SeparatorView"]) {
subview.hidden = NO;
}
}
}
}

#pragma mark - Background Support
-(BOOL) selectedOrHighlighted
{
return [self isSelected] || [self isHighlighted];
Expand Down
3 changes: 2 additions & 1 deletion iphone/Classes/TiUIListView.m
Expand Up @@ -246,6 +246,7 @@ - (void) updateIndicesForVisibleRows
UITableViewCell* theCell = [_tableView cellForRowAtIndexPath:vIndexPath];
if ([theCell isKindOfClass:[TiUIListItem class]]) {
((TiUIListItem*)theCell).proxy.indexPath = vIndexPath;
[((TiUIListItem*)theCell) ensureVisibleSelectorWithTableView:_tableView];
}
}];
}
Expand Down Expand Up @@ -1043,7 +1044,7 @@ - (void)tableView:(UITableView *)tableView didEndEditingRowAtIndexPath:(NSIndexP
editing = [_tableView isEditing];
[self.proxy replaceValue:NUMBOOL(editing) forKey:@"editing" notification:NO];
if (!editing) {
[_tableView reloadData];
[_tableView performSelector:@selector(reloadData) withObject:nil afterDelay:0.1];
}
}

Expand Down
3 changes: 3 additions & 0 deletions iphone/Classes/TiUITableView.m
Expand Up @@ -420,6 +420,9 @@ -(UITableView*)tableView
if (TiDimensionIsDip(rowHeight))
{
[tableview setRowHeight:rowHeight.value];
} else if ([TiUtils isIOS8OrGreater]) {
//TIMOB-17373 rowHeight on iOS8 is -1. Bug??
[tableview setRowHeight:44];
}

BOOL initBackGround = YES;
Expand Down
6 changes: 6 additions & 0 deletions iphone/Classes/TiUtils.h
Expand Up @@ -563,6 +563,12 @@ typedef enum
*/
+(BOOL)isIOS7OrGreater;

/**
Whether or not the current OS version is equal to or greater than 8.0.
@return _YES_ if the current OS version is equal to or greater thann 8.0, _NO_ otherwise.
*/
+(BOOL)isIOS8OrGreater;

/**
Whether or not the current device is an iPhone 4.
@return _YES_ if the current device is an iPhone 4, _NO_ otherwise.
Expand Down
5 changes: 5 additions & 0 deletions iphone/Classes/TiUtils.m
Expand Up @@ -167,6 +167,11 @@ +(BOOL)isIOS7OrGreater
return [UIViewController instancesRespondToSelector:@selector(childViewControllerForStatusBarStyle)];
}

+(BOOL)isIOS8OrGreater
{
return [UIView instancesRespondToSelector:@selector(layoutMarginsDidChange)];
}

+(BOOL)isIPad
{
return [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad;
Expand Down

0 comments on commit 57aaa22

Please sign in to comment.