user1628700
user1628700

Reputation: 328

No '-addSubView' method found

I get "no '-addSubView' method found "

when I try to add a subview to a window, in this case trying to add a button. Here is my code

@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

Upvotes: 0

Views: 328

Answers (1)

RavuAlHemio
RavuAlHemio

Reputation: 2371

The message is called addSubview:, not addSubView:.

[[ui window] addSubview:myButton];

Upvotes: 1

Related Questions