I\'ve created a sub class of UIButton:
//
// DetailButton.h
#import
#import
@interface MyDetailButt
UIButton is a class cluster, which implies that Apple's implementation of buttonWithType:
probably looks something like this:
+(id)buttonWithType:(UIButtonType)t {
switch (t) {
case UIButtonTypeDetailDisclosure:
return [[[PrivateDetailDisclosureButtonClass alloc] init] autorelease];
case ...
}
}
So when you call [MyDetailButton buttonWithType:UIButtonTypeDetailDisclosure];
you don't get an instance of MyDetailButton
, you get an instance of PrivateDetailDisclosureButtonClass
(or whatever Apple actually calls it).
Note, however, that you can get buttonWithType
to instantiate a subclass if you call it with UIButtonTypeCustom
(At least in the simulator running v3.0):
// LGButton is a straightforward subclass of UIButton
LGButton *testBtn = [LGButton buttonWithType:UIButtonTypeCustom];
LGButton *testBtn2 = [LGButton buttonWithType:UIButtonTypeDetailDisclosure];
NSLog(@"testBtn: %@, testBtn2: %@", [testBtn class], [testBtn2 class]);
// Output: testBtn: LGButton, testBtn2: UIButton