我想分類的UIBUTTON類,並添加一些額外的手段。iPhone,試圖繼承UIButton和meeds所有崩潰,當你打電話給他們
如果我ceate一類如下
cTest *mTest=[cTest buttonWithType:UIButtonTypeRoundedRect];
和調用任何基法,一個我創建或媒體鏈接存在,例如[cTest setTitle:@"test" forState: UIControlStateNormal];
崩潰。
我CTEST類:
#import <Foundation/Foundation.h>
@interface cTest : UIButton {
int i;
}
-(void) aTest;
@end
代碼來測試類:
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
// this works fine
UIButton *mBut=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[mBut setTitle:@"test" forState: UIControlStateNormal];
// this does NOT
cTest *mTest=[cTest buttonWithType:UIButtonTypeRoundedRect];
[cTest setTitle:@"test" forState: UIControlStateNormal];
[mTest aTest]; // crashes here does not call my function
}
特德