iPhone:MKAnnotation 中的循环导入警告​​:未找到方法

发布于 2024-08-22 05:27:48 字数 1583 浏览 6 评论 0原文

我刚刚通过使用类转发解决了循环依赖问题。现在,我收到一条警告,提示未找到“showSumDetails”方法。我根本不明白为什么会发生这种情况,任何帮助将不胜感激。这里包括一些代码:

MyAnnotation.h

#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
//#import "MyMapViewController.h" obviously this wasn't possible :-(
@class MyMapViewController;

@interface MyAnnotation : NSObject<MKAnnotation> {


    MyMapViewController* mapController;
}

MyMapViewController.h

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <MapKit/MKReverseGeocoder.h>
#import "MyAnnotation.h"

@interface MyMapViewController : UIViewController <MKMapViewDelegate>{

    MyAnnotation *annot;
}

MyMapViewController.m - 该方法实际存在的位置,并且也在头文件中定义。

 @implementation MyMapViewController

    @synthesize annot; 

    -(void) showSumDetails:(id)aSumData{
    NSLog(@"mapViewController-showSumDetails");
    SumDetailsViewController *wrController = [[SumDetailsViewController alloc] init];
    wrController.sumData = aSumData;
    [self.navigationController pushViewController:wrController animated:YES];//This needs to be pushed
    [wrController release];
}
@end

但是 MyAnnotation.m 中的以下方法找不到上面的方法:-(

@implementation MyAnnotation

@synthesize sumData;
@synthesize mapController;    

- (void) showPD{//is also defined in header file
        NSLog(@"sPD - MyAnn");

        [mapController showSumDetails:sumData]; //This doesn't have a clue about showSumDetails method- Why??
    }

我很乐意提供更多信息。请帮忙!!!

I just resolved a cyclic dependency problem by using class forwarding. Now, I am getting a warning of no 'showSumDetails' method found. I don't understand why it should happen at all, any help will be appreciated. Including a bit of code here:

MyAnnotation.h

#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
//#import "MyMapViewController.h" obviously this wasn't possible :-(
@class MyMapViewController;

@interface MyAnnotation : NSObject<MKAnnotation> {


    MyMapViewController* mapController;
}

MyMapViewController.h

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <MapKit/MKReverseGeocoder.h>
#import "MyAnnotation.h"

@interface MyMapViewController : UIViewController <MKMapViewDelegate>{

    MyAnnotation *annot;
}

MyMapViewController.m - where the method actually exists, and it is defined in the header file as well.

 @implementation MyMapViewController

    @synthesize annot; 

    -(void) showSumDetails:(id)aSumData{
    NSLog(@"mapViewController-showSumDetails");
    SumDetailsViewController *wrController = [[SumDetailsViewController alloc] init];
    wrController.sumData = aSumData;
    [self.navigationController pushViewController:wrController animated:YES];//This needs to be pushed
    [wrController release];
}
@end

But the following method in MyAnnotation.m can't find the method above :-(

@implementation MyAnnotation

@synthesize sumData;
@synthesize mapController;    

- (void) showPD{//is also defined in header file
        NSLog(@"sPD - MyAnn");

        [mapController showSumDetails:sumData]; //This doesn't have a clue about showSumDetails method- Why??
    }

I'd be glad to provide any more info. Please help!!!

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

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

发布评论

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

评论(1

牵你手 2024-08-29 05:27:48

您是否在 MyAnnotation.m 中导入了 MyMapViewController.h ?

由于您在 MyAnnotation.h 中使用 MyMapViewController 的前向引用,因此您需要在 MyAnnotation.m 中导入 MyMapViewController.h。

Did you import MyMapViewController.h in MyAnnotation.m?

Since you're using a forward reference for MyMapViewController in MyAnnotation.h you need to import MyMapViewController.h in MyAnnotation.m.

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