1

目前我遇到了一个非常烦人的问题,试图创建一个覆盖以在搜索时提供一个灰色的界面,然后当它被触摸时将其关闭。

我已经从我的应用程序的另一部分改编了一些代码,对我来说它们是完全一样的,期望变量名发生变化等。

这是两个头文件进行比较

联系人搜索覆盖:

#import <UIKit/UIKit.h>
@class Contacts;
@interface Overlay : UIViewController{
    Contacts *Contact;
}
@property(nonatomic,retain) Contacts *Contact;
@end

地图搜索覆盖:

#import <UIKit/UIKit.h>
@class Map;
@interface mapOverlay : UIViewController{
    Map *searcher;
}
@property(nonatomic,retain) Map *searcher;
@end

以及用于比较的两个方法文件

联系人搜索覆盖:

#import "Overlay.h"
#import "Contacts.h"
@implementation Overlay
   @synthesize Contact;
   - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
      [Contact doneSearching_Clicked:nil];
   }
   - (void)dealloc {
      [Contact release];
      [super dealloc];
   }
@end

地图搜索覆盖:

#import "mapOverlay.h"
#import "Map.h"
@implementation mapOverlay
    @synthesize searcher;
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
        [searcher doneSearching_Clicked:nil];
    }
    - (void)dealloc {
       [searcher release];
       [super dealloc];
    }
@end

所以它们都是完全相同的,并且调用的是同一个函数。

这是联系人和地图类的标题

联系人

#import <UIKit/UIKit.h>
@class Overlay;
@interface Contacts : UIViewController <NSXMLParserDelegate , UISearchBarDelegate>{
     Overlay *searchOverlay;
}
- (void)doneSearching_Clicked:(id)sender;
@end

地图

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
@protocol ModalViewDelegate

- (void)didReceiveMessage:(NSString *)message fromwho:(NSInteger )whichText;

@end
@class mapOverlay;
@interface Map : UIViewController<MKMapViewDelegate,NSXMLParserDelegate, ModalViewDelegate> {
    mapOverlay *searchOverlay;
}
- (void)doneSearching_Clicked:(id)sender;
@end

我真的很难过。我很确定我没有做错任何事,因为两种实现方式完全相同。唯一的区别是 Map 类有一个模态视图的委托。我已经把它拿出来尝试了,但仍然没有运气。

我已经检查以确保两个视图都记录了它们的触摸。似乎用于地图的叠加层并未将消息发送到 Map 类。

有谁知道是什么可能导致它在一个工作而不是另一个工作?

4

0 回答 0