找不到'-addSubView'方法

时间:2012-08-30 23:40:40

标签: iphone objective-c

我发现“没有'-addSubView'方法”

当我尝试将子视图添加到窗口时,在这种情况下尝试添加按钮。这是我的代码

@interface SBUIController 

-(id)window;

@end


@interface SBAwayView 

-(void)chargingView;
-(void)showChargingView;
-(void)hideChargingView;
-(void)showBulletinView;
-(BOOL)shouldShowChargingView;
-(void)hideCameraButton;

@end

%hook SBAwayController

-(void)_tearDownCameraPreview{

//SBAwayView *v = MSHookIvar<id>(self, //"_awayView");

UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; myButton.frame = CGRectMake(21, 80, 100, 35); [myButton setTitle:@"My Button" forState:UIControlStateNormal];

SBUIController *ui = MSHookIvar<id>(self, "_uiController");


[[ui window] addSubView:myButton];

%orig; }

%end

1 个答案:

答案 0 :(得分:1)

邮件名为addSubview:,而不是addSubView:

[[ui window] addSubview:myButton];