0

OK, I got it to codesign (turns out you don't need to see the code sign and embedded.mobileprovision in the build log anymore!) but I want to get rid of my "may not respond to" warnings. I cannot find the problem after looking at all the other posts about these warnings...

In the Welcome_backView.h:

 @interface Welcome_backView : UIView {
Welcome_backViewController *refParentViewController;

}


- (id)initWithParentViewController:(Welcome_backViewController *)parent;
- (void)setSubviewsToLandscape;
- (void)setSubviewsToPortrait;

In the Welcome_back.m,

  #import "Welcome_backView.h"
  #import "Welcome_backViewController.h"
  @interface Welcome_backView()
//

@end

@implementation Welcome_backView



 - (void)setSubviewsToPortrait{
//do great things
 }

 - (void)setSubviewsToLandscape{
    //do more great things
 }

Then this is from Welcome_backViewController.m:

#import "Welcome_backViewController.h"
#import "Welcome_backView.h"

@interface Welcome_backViewController()
-(void) arrangeViews;
@end

@implementation Welcome_backViewController

UIView *welcome_backView;

 - (id)init {

welcome_backView = [[Welcome_backView alloc] initWithParentViewController:self];
    self.view = welcome_backView;
}

-(void) arrangeViews {
//if one thing
    [welcome_backView setSubviewsToPortrait];
//if another thing
    [welcome_backView setSubviewsToLandscape];
}

And, like so many posters, I get the warnings "UIView" may not respond to "-setSubviewsToLandscape" (and to portrait...same warning). I have tried all the usual suspects -- misspellings of the method, using the class instead of the instance, not importing the header or having forgotten to put the method declarations in the header.

Truth is, the code seems to work fine...

Can anyone see what I've done wrong (can I get rid of the warnings)?

snorkelt
  • 57
  • 6
  • The warning is "UIView may not respond..." not "Welcome_backView may not respond..."? –  Nov 08 '10 at 03:12
  • Yes, specifically: 'UIView' may not respond to '-setSubviewsToPortrait'...and this is for 12 of my views, so I am doing something wrong systematically. – snorkelt Nov 08 '10 at 14:32
  • How is the welcome_backView ivar declared? –  Nov 08 '10 at 17:47
  • Thank you for catching that! I cut-and-pasted incorrectly and have edited the original post. That ivar is declared in the viewController as you can see in the correction. I'm glad you found that...sorry! – snorkelt Nov 09 '10 at 14:37

1 Answers1

0

The warning is saying "UIView may not respond..." because you've declared the welcome_backView ivar as a UIVIew instead of your subclass of it.

UIView doesn't have the methods setSubviewsToXXX--your subclass of it does.

Change this:

UIView *welcome_backView;

to this:

Welcome_backView *welcome_backView;

It works even when declared as UIView because at run-time, the ivar does point to an instance of Welcome_backView which responds to the setSubviewsToXXX methods.

Another thing that isn't causing problems (yet) is the names of the methods. Method names starting with "set" are generally used for property setter methods and could later cause confusion.

  • Got it! That was all it needed. Didn't notice the "set" problem either. Thanks so much for your help. – snorkelt Nov 09 '10 at 19:38