문제

사용 중입니다 http://github.com/facebook/three20 내 iPhone 응용 프로그램에서. 프로젝트에 프레임 워크를 포함하도록 지침을 따랐습니다. 나는 지금 그것을 두 번 확인했다 (Google Group 및 IRC의 사람들의 권장 사항에서). 320 개의 코드 중 일부가 UIView에서 카탈로그 된 선택기를 사용하려고 시도하면 다음과 같은 오류가 발생합니다.

-[ttSearchTextField ANCESTORORSELFEFLSFCLASS :] : 인스턴스로 보낸 인식이없는 선택기 0x3A85ee0 '

이 예외는 텍스트 필드를 터치 할 때 트리거됩니다.

여기에 키커는 다음과 같습니다. ttsearchTextField에 데이터 소스를 할당하지 않으면 오류를 유발하지 않습니다. 그래서 논리적으로 나는 그것이 내 데이터 소스 여야한다고 생각했습니다.

  1. 데이터 소스의 모든 기능에 중점을 두었습니다.
  2. 예상대로 이르가 전화를 받고 액세서 대의원이 호출되었습니다.
  3. 텍스트 필드를 탭하면 데이터 소스에 대한 호출이 없으며 런타임 예외가 발생합니다.

나는 이것에 머물러있다. 나는 이전에 카탈로그와 함께 외부 Libs를 사용하는 데 문제가 없었습니다. 프로젝트 설정에 대한 자세한 정보를 제공 할 수 있습니다. 약간의 정보가 있기 때문에 구체적인 내용을 요청하십시오.

코드 나는 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: uiview를 확장하고 추가되는 카테고리 메소드입니다. UIViewAdditions.h. 데이터 소스를 추가 할 때 오류가 발생하는 이유는 아마도 모든 코드가 -ancestorOrSelfWithClass: 데이터 소스가 할당되지 않은 경우 메시지가 호출되지 않을 수 있습니다.

iPhone 응용 프로그램에 포함시키기 위해 정적 라이브러리를 컴파일 할 때 2.x 아래에 추가해야합니다. -ObjC 다른 링커 플래그에 카테고리 메소드가 라이브러리에 연결되어 있는지 확인하십시오. 3.x에서는 제대로 작동하지 않는 것 같습니다.all_load 다른 링커 플래그에도 추가해야합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top