无法在超级视图中调用方法(尽管在应用程序的其他部分工作)
我目前遇到一个非常烦人的问题,同时尝试创建一个覆盖层以在搜索时提供灰色界面,然后在触摸它时将其关闭。
我已经从我的应用程序的另一部分改编了一些代码,对我来说它们是完全相同的,期望变量名称发生变化等。
这是用于比较的两个头文件
联系人搜索覆盖:
#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 类。
有谁知道什么可能导致它在其中一个中起作用,但在另一个中不起作用?
I've got a really annoying issue at the moment while trying to create an overlay to provide a greyed out interface when searching and then when it's touched dismiss it.
I've adapted some code from another part of my app and to me they are completely the same, expect the variable name changes etc.
Here's the two header files for comparison
Contacts search overlay:
#import <UIKit/UIKit.h>
@class Contacts;
@interface Overlay : UIViewController{
Contacts *Contact;
}
@property(nonatomic,retain) Contacts *Contact;
@end
Map search overlay:
#import <UIKit/UIKit.h>
@class Map;
@interface mapOverlay : UIViewController{
Map *searcher;
}
@property(nonatomic,retain) Map *searcher;
@end
And the two method files for comparison
Contacts search overlay:
#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
Map search overlay:
#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
So both of them are exactly the same, and are calling the same function.
Here's the headers for the Contacts and Map classes
Contacts
#import <UIKit/UIKit.h>
@class Overlay;
@interface Contacts : UIViewController <NSXMLParserDelegate , UISearchBarDelegate>{
Overlay *searchOverlay;
}
- (void)doneSearching_Clicked:(id)sender;
@end
Map
#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
I'm really stumped with this. I'm pretty sure that I've done nothing wrong as both implementations are exactly the same. The only difference is that the Map class has a delegate for a modalview. I've taken this out and tried but still no luck.
I've checked to make sure that both views are registering the touches which they are. It just appears that the overlay used for the map is not sending the message to the Map class.
Does anyone have an idea what could be causing it work in one but not the other?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论