내가 아이폰 OS의 새로운이야 전송 생산, 그리고 정말 미안 @protocol 구현에 문제가 내가 stackoverflow.com, 웹 주위를 검색하고 잠시 동안 구글 삼촌을 시도하고 여기에 물어보기로 결정했습니다 ...실패 self.delegate를 할당에</p> <p>내가 '.. 그것을 인식 할 수없는 선택기
주요 아이디어는 TopViewController에서 MyViewController를 호출하고 플립 애니메이션을 수행하는 것입니다. 나는 프로토콜 ..
// This is my Delegate header
// MyViewController.h
@protocol MyViewControllerlDelegate
- (void) myViewControllerDidFinish;
@end
@interface MyViewController : UIViewController
{
id <MyViewControllerlDelegate> delegate;
}
@property (nonatomic, assign) id <MyViewControllerlDelegate> delegate;
- (IBAction) done;
@end
아래 10
및 구현에 :
내가 개체 이상 사용// MyViewController.m
#import "MyViewController.h"
@implementation MyViewController
@synthesize delegate;
// Another Code above
- (IBAction)done
{
[self.delegate myViewControllerDidFinish];
}
// Another Code Below
@end
아래 다른보기에서 호출 그 안에 플립 전환을 추가 할 :
// TopViewController.h
#import "MyViewController.h"
@class MapScrollView;
@interface TopViewController : UIViewController <UIScrollViewDelegate,MyViewControllerlDelegate>
{
UIScrollView *topScrollView;
UIButton *infoButton;
}
@end
TopViewController.h 구현 // TopViewController. m
컴파일러 에러 다음 코드 생산 아래#import "TopViewController.h"
#import "CustomScrollView.h"
#import <QuartzCore/QuartzCore.h>
- (void)loadView
{
// Step 1: make the outer paging scroll view
CGRect topScrollViewRect = [[UIScreen mainScreen] bounds];
topScrollView = [[UIScrollView alloc] initWithFrame:topScrollViewRect];
topScrollView.pagingEnabled = YES;
topScrollView.backgroundColor = [UIColor blackColor];
topScrollView.showsVerticalScrollIndicator = NO;
topScrollView.showsHorizontalScrollIndicator = NO;
topScrollView.contentSize = CGSizeMake(topScrollViewRecte.size.width,
topScrollViewRecte.size.height);
topScrollView.delegate = self;
self.view = pagingScrollView;
CustomScrollView *sView = [[[MapScrollView alloc] init] autorelease];
sView.frame = [[UIScreen mainScreen] bounds];
[sView displayTiledMap];
[pagingScrollView addSubview:sView];
// add Info Button
UIButton *button = [UIButton buttonWithType:UIButtonTypeInfoDark];
[button addTarget:self action:@selector(infoIsTouch:) forControlEvents:UIControlEventTouchDown];
button.frame = CGRectMake(282.0, 440.0, 18.0, 19.0);
[self.view addSubview:button];
}
-(void)infoIsTouch:(id)sender
{
MyViewController *myView =
[[MyViewController alloc] initWithNibName:@"MyViewController" bundle:[NSBundle mainBundle]];
myView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
//
//Here where the code is crash
//
[myView setDelegate:self];
//
//Code from here to below is not run...
//
[self presentModalViewController:myView animated:YES];
[myView release];
}
- (void) myViewControllerDidFinish
{
[self dismissModalViewControllerAnimated:YES];
}
etc...
@end
..
2010-12-06 01:09:07.946 MyViewDelegatePractice[9473:207] -[TopViewController setDelegate:]: unrecognized selector sent to instance 0x5f30fb0
2010-12-06 01:09:07.949 MyViewDelegatePractice[9473:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TopViewController setDelegate:]: unrecognized selector sent to instance 0x5f30fb0'
*** Call stack at first throw:
(
// Cuts...
)
terminate called after throwing an instance of 'NSException'
내가 전화 infoButton 누를 때 이러한 오류가 발생합니다 - (무효) infoIsTouch (ID) 발송 방법, 다음 [MYVIEW의 setDelegate : 자기]에서 막을 내 실수입니다 줄은 ... 사람이 나에게 힌트를 줄 수 뭐야?
참고 : 내 영어와 혐오 경우 .. 또한 접경 의견을 자유롭게 떨어졌다 ..하지만 그 전에 .. 내가
'MyViewControllerlDelegate' 및'FanglesMapSettingViewControllerDelegate' 중 어느 것을 구현해야합니까? 나는 혼란스러워. – BoltClock
@ sam-ritchie @ sam-ritchie - 감사합니다. sam, 내 오타입니다. 변수를 변경하는 것을 잊었습니다. 죄송합니다. .. – FerryHtw
FanglesMapSettingViewControllerDelegate를 MyViewControllerlDelegate로 변경했지만 여전히 같은 오류가 발생합니다 .. – FerryHtw