is this code future proof for customising color of

2019-08-30 05:55发布

is this code future proof for customising color of EKEventViews (code attached)? i.e should it be ok as apple rev's versions of IOS.

if not, what code would you recommend?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {   
    self.detailViewController = [[EKEventViewController alloc] initWithNibName:nil bundle:nil];         
    detailViewController.event = [self.eventsList objectAtIndex:indexPath.row];
    [self.navigationController pushViewController:detailViewController animated:YES];

    // CODE UNDER QUESTION HERE
    UITableView *tv = (UITableView*)[detailViewController.view.subviews objectAtIndex:0];
    [tv setBackgroundColor:[UIColor yellowColor]];
    UIView *v = (UIView*)[[tv visibleCells] objectAtIndex:0];
    v.backgroundColor = [UIColor greenColor];
}

1条回答
趁早两清
2楼-- · 2019-08-30 06:41

It's perfectly valid now, but Apple at any time could change the structure of the UITableView or EKEventViewController breaking your customizations. Try looking into the new tintColor properties. Also, where do you interact with the table view otherwise? You're not just presenting it and leaving it, correct? Therefore, where else can you possibly change it. I need more code to help. You can also just set [detailViewController.view.subviews objectAtIndex:0].backgroundColor' to[UIColor yellowColor]` and likewise.

查看更多
登录 后发表回答