这是我的协议
#import <UIKit/UIKit.h>
#import "HypnosisterView.h"
@interface HypnosisterAppDelegate : UIResponder <UIApplicationDelegate,UIScrollViewDelegate>
{
HypnosisterView *view;
}
@property (strong, nonatomic) UIWindow *window;
@end
这是委托的实现
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
CGRect screenRect = [[self window]bounds];
UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:screenRect];
[scrollView setMaximumZoomScale:1.0];
[scrollView setMaximumZoomScale:5.0];
[scrollView setDelegate:self];
[[self window]addSubview:scrollView];
CGRect bigRect = screenRect;
view = [[HypnosisterView alloc]initWithFrame:screenRect];
[scrollView addSubview:view];
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return view;
}
[scrollView setContentSize:bigRect.size];
BOOL success = [view becomeFirstResponder];
if (success) {
NSLog(@"HypnosisView became the first responder");
}else{
NSLog(@"Couldn't become first responder");
}
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
即使在确认协议给出错误未声明的标识符 viewForZoomingInScrollView 之后。 我已经从苹果文档中复制了这个方法,并通过跳转到该委托的定义进行了交叉验证。它显示未声明的这就是为什么也没有出现在自动建议中。请帮帮我。感谢。