응용 프로그램이 시작될 때 설정 기본 설정에서 사용자가 사용 조건을 수락하지 않은 것으로 나타 났을 때 서비스 모달보기를 표시하려고합니다. " '* MyAppAppDelegate'imcompatible 유형에서 'ID'로 지정"appDelegate가 모달 뷰 대리자 일 수 있습니까?
if (TOSAcceptedPrefValue) { //has not been accepted
// Create the root view controller for the navigation controller
TermsOfServiceController *termsOfServiceController = [[TermsOfServiceController alloc]
initWithNibName:@"TermsOfServiceController" bundle:nil];
// Create the navigation controller and present it modally.
UINavigationController *navigationController = [[UINavigationController alloc]
initWithRootViewController:termsOfServiceController];
termsOfServiceController.delegate = self;
navigationController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:navigationController animated:YES];
[navigationController release];
[TermsOfServiceController release];
NSLog(@"1");
}
그러나, 엑스 코드는 termsOfServiceController.delegate = 자기 것을 나타내는한다 :
는 그래서 ApplicationDidFinishLaunchingWithOptions 내 AppDelegate에, 나는이 코드를 가지고 .@protocol TOSModalViewDelegate
- (void)didAcceptTermsOfService:(NSString *)message;
- (void)didRejectTermsOfService:(NSString *)message;
@end
@interface MyAppAppDelegate : NSObject <UIApplicationDelegate, TOSModalViewDelegate> ...
과 modalview 헤더
:@protocol ModalViewDelegate ;
@interface TermsOfServiceController : UIViewController {
id<ModalViewDelegate> delegate; ...
...
@property (nonatomic, assign) id<ModalViewDelegate> delegate;
을하고 난 modalview의 된 구현 파일에 합성
나는 완전히 내 AppDelegate에 헤더에 모달 프로토콜을 구현 생각합니다.
이 example에 따라 AppDelegate.m 파일의 코드가 인스턴스화 된 후에도 코드가 이동되었지만 여전히 Xcode의 경고가 표시됩니다.
이 오류로 앱 충돌의 경고 결과
: 이2011-09-05 08:34:12.237 MyApp[4416:207] TOSAcceptedPrefValue = 0 2011-09-05 08:34:13.732 MyApp[4416:207] displayWelcomeScreenPrefValue = 0 2011-09-05 08:34:42.889 MyApp[4416:207] -[MyAppAppDelegate presentModalViewController:animated:]: unrecognized selector sent to instance 0x552b430 2011-09-05 08:34:42.892 MyApp[4416:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MyAppAppDelegate presentModalViewController:animated:]: unrecognized selector sent to instance 0x552b430'
그래서 제 질문은, 그것은 가능 AppDelegate에에서 모달보기를 표시하고, 내가 할 무엇을 변경해야 그렇다면 그것이 일어날 것입니다 . MyAppAppDelegate
이 UIViewController
서브 클래스가 아닌, 따라서 presentModalViewController:animated:
을 처리 할 수 없기 때문에 당신의 도움
좋습니다. 설명 주셔서 감사합니다! AppDelegate를 통해 정상적인 첫 번째보기 컨트롤러 (프로필보기)를 표시하도록 설정했으나 즉시 프로필보기 컨트롤러가 viewdidload를 체크하여 서비스 약관을 표시해야하는지 확인합니다. – Jazzmine
맞습니다. 세부 사항은 이전과 마찬가지로 정확히 수행해야 할 작업에 달려 있습니다. –