我有不同的“可能不会回应”吗?警告问题?

发布于 2024-09-30 23:50:28 字数 1478 浏览 5 评论 0原文

好的,我让它进行了协同设计(事实证明您不再需要在构建日志中看到代码符号和嵌入的.mobileprovision!)但我想摆脱我的“可能不会响应”警告。在查看有关这些警告的所有其他帖子后,我找不到问题...

在Welcome_backView.h中:

 @interface Welcome_backView : UIView {
Welcome_backViewController *refParentViewController;

}


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

在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
 }

然后这是来自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];
}

并且,像许多海报一样,我收到警告“ UIView”可能不会响应“-setSubviewsToLandscape”(以及纵向......相同的警告)。我已经尝试了所有常见的嫌疑——方法的拼写错误、使用类而不是实例、没有导入标头或者忘记将方法声明放在标头中。

事实是,代码似乎工作正常......

任何人都可以看到我做错了什么(我可以摆脱警告)吗?

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)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吻泪 2024-10-07 23:50:28

警告说“UIView 可能不会响应...”,因为您已将welcome_backView ivar 声明为 UIVIew 而不是它的子类。

UIView 没有 setSubviewsToXXX 方法——你的子类有。

将其更改

UIView *welcome_backView;

为:

Welcome_backView *welcome_backView;

即使声明为 UIView,它也可以工作,因为在运行时,ivar 确实指向响应 setSubviewsToXXX 方法的 Welcome_backView 实例。

另一件尚未引起问题的事情是方法的名称。以“set”开头的方法名称通常用于属性设置方法,稍后可能会引起混淆。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文