Browse files

Avoiding using routeButton.

A lot of ugly tricks here, but there is no other
way to do this things.
  • Loading branch information...
1 parent 912b629 commit fc18d46106a97d9b2507e2e304ad894ae3873925 @drodriguez committed Jul 3, 2009
Showing with 16 additions and 12 deletions.
  1. +16 −12 Classes/RRQVolumeView.m
View
28 Classes/RRQVolumeView.m
@@ -20,18 +20,11 @@ - (UIButton *)routeButton;
@implementation RRQVolumeView
-/*
+
- (void)layoutSubviews {
- if (!layoutDone) {
- NSLog(@"layoutSubviews");
- layoutDone = TRUE;
- if ([self respondsToSelector:@selector(routeButton)]) {
- [[self routeButton] removeFromSuperview];
- [self setValue:nil forKeyPath:@"_internal._routeButton"];
- }
- }
+ // Layout subviews must be overriden, but do not have to do nothing.
}
- */
+
- (void)setShowsRouteButton:(BOOL)value animated:(BOOL)animated {
NSLog(@"setShowsRouteButton:%@ animated:%@",
@@ -71,14 +64,25 @@ - (void)finalSetup {
}
- (void)_createSubviews {
- [super _createSubviews];
+ // The same than [super _createSubviews]
+ IMP methodImp = [MPVolumeView instanceMethodForSelector:_cmd];
+ methodImp(self, _cmd);
- NSLog(@"_createSubviews\n%@", self);
+ // Brittle, but Apple get us if we use the other way.
+ // Lets hope they do not use _internal._routeButton a lot.
+ for (UIView *view in self.subviews) {
+ if ([view isKindOfClass:[UIButton class]]) {
+ [view removeFromSuperview];
+ }
+ }
+ // Alternative implementation, using private APIs
+ /*
if ([self respondsToSelector:@selector(routeButton)]) {
[[self routeButton] removeFromSuperview];
[self setValue:nil forKeyPath:@"_internal._routeButton"];
}
+ /**/
}
@end

0 comments on commit fc18d46

Please sign in to comment.