缺少选择从Obj-c Three20图书馆目录
-
19-09-2019 - |
题
我在使用 http://github.com/facebook/three20 在我的iPhone应用程序。我已经遵循了指令包括该框架在我的项目。我已经核实它现在的两倍(在建议的人在谷歌组和IRC)。我得到的以下错误时有一些Three20码试图使用一个目录器上):
-[TTSearchTextField ancestorOrSelfWithClass:]:无法识别的选择发送到实例0x3a85ee0'
这一例外的是触发当我触摸的文本的领域。
这是踢我,如果我没有分配一个数据源的TTSearchTextField它不会触发的错误。因此,从逻辑上讲我想这必须是我的数据源。
- 我放一个突破点在每一个功能在我的数据来源。
- 跑的程序,预期初始被称与访问的代表。
- 窃听文字,没有电话到我的数据源和运行时间异常发生。
我难住了这一点。我从来没有问题,使用外部库,与目录在他们之前。我可以提供更多的信息,项目的设置,只是要求对具体情况,因为有相当多的信息。
代码,我在使用的创建TTSearchTextField:
// setup Country
self.searchFieldCountry = [[TTSearchTextField alloc]initWithFrame:CGRectMake(156, 145, 146, 37)];
self.searchFieldCountry.borderStyle = UITextBorderStyleRoundedRect;
self.searchFieldCountry.placeholder = @"Country";
self.searchFieldCountry.autocapitalizationType = UITextAutocapitalizationTypeNone;
OLLocationSearchDataSource *ds = [[OLLocationSearchDataSource alloc]init];
self.searchFieldCountry.dataSource = ds;
[self.view addSubview:self.searchFieldCountry];
[ds release];
码我的数据源:
#import "OLLocation.h"
#import "AppSession.h"
@implementation OLLocation
@synthesize locationData = _locationData;
@synthesize locationMode,country,region;
- (NSMutableArray*)delegates {
if (!_delegates) {
_delegates = TTCreateNonRetainingArray();
}
return _delegates;
}
- (BOOL)isLoadingMore {
return NO;
}
- (BOOL)isOutdated {
return NO;
}
- (BOOL)isLoaded {
return !!_AllLocationData;
}
- (BOOL)isLoading {
return NO;
}
- (BOOL)isEmpty {
return !_AllLocationData.count;
}
- (void)load:(TTURLRequestCachePolicy)cachePolicy more:(BOOL)more {
}
- (void)invalidate:(BOOL)erase {
}
- (void)cancel {
// cancel a search if possible
}
- (void)loadNames {
_AllLocationData = [[AppSession getAppSession] getCountries];
}
- (void)search:(NSString*)text {
[self cancel];
self.locationData = [NSMutableArray array];
if (text.length) {
text = [text lowercaseString];
for (NSString* name in _AllLocationData) {
if ([[name lowercaseString] rangeOfString:text].location == 0) {
[_locationData addObject:name];
}
}
}
}
- (void)dealloc {
[super dealloc];
}
@end
@implementation OLLocationSearchDataSource
@synthesize locations = _locations;
-(id)init {
if (self = [super init]) {
_locations = [[OLLocation alloc] init];
_locations.locationMode = OLLocationModeCountry;
self.model = _locations;
}
return self;
}
-(void)dealloc {
TT_RELEASE_SAFELY(_locations);
[super dealloc];
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// TTTableViewDataSource
- (void)tableViewDidLoadModel:(UITableView*)tableView {
self.items = [NSMutableArray array];
for (NSString* name in _locations.locationData) {
TTTableItem* item = [TTTableTextItem itemWithText:name URL:@"http://google.com"];
[_items addObject:item];
}
}
- (void)search:(NSString*)text {
[_locations search:text];
}
- (NSString*)titleForLoading:(BOOL)reloading {
return @"Searching...";
}
- (NSString*)titleForNoData {
return @"No names found";
}
@end
解决方案
我觉得这不是你的数据来源。 -ancestorOrSelfWithClass:
是一种类别的方法的延伸)和加入 UIViewAdditions.h
.原因你的错误,当添加数据来源可能是什么代码发送的 -ancestorOrSelfWithClass:
消息可能不被称为如果数据来源是未分配。
当编制的静态图书馆对纳入iPhone应用程序,在2.x你需要添加 -ObjC
你其他的接头的标志,以确保类别的方法联系到的图书馆。3.x,这似乎不正常工作,所以-all_load
需要增加,以及其他接头的标志。
不隶属于 StackOverflow