ローカル変数をインスタンス変数に変更した後、コードに問題が発生しています。具体的には、次のコードから1行を変更した後、HypnosisterAppDelegate.mファイルのコードで問題が発生しました。
HypnosisView *view = [[HypnosisView alloc]initWithFrame:screenRect];
に
view = [[HypnosisView alloc]initWithFrame:screenRect];
HypnosisterAppDelegate.mのエラーメッセージをコメントアウトしました。何が問題なのか教えていただけますか?前もって感謝します。
HypnosisterAppDelegate.m
#import "HypnosisterAppDelegate.h"
#import "HypnosisView.h"
@implementation HypnosisterAppDelegate
@synthesize window = _window;
- (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];
// Create the UIScrollView to have the size of a window, matching its size
view = [[HypnosisView alloc]initWithFrame:screenRect];
[scrollView setMinimumZoomScale:1.0]; // Unknown receiver "scrollView"; should it be "UIScrollView"?
[scrollView setMaximumZoomScale:5.0]; // Unknown receiver "scrollView"; should it be "UIScrollView"?
//You will get a warning here, ignore it for now
[scrollView setDelegate:self]; // Unknown receiver "scrollView"; should it be "UIScrollView"?
[[self window] addSubview:scrollView]; // Unknown receiver "scrollView"; should it be "UIScrollView"?
//Create the HypnosisView with a frame that is twice the size of the screen
CGRect bigRect = screenRect;
HypnosisView *view = [[HypnosisView alloc]initWithFrame:screenRect];
// Add the HypnosisView as a subview of the scrollView instead of the window
[scrollView addSubview:view]; // Unknown receiver "scrollView"; should it be "UIScrollView"?
// Tell the scrollView how big its virtual world is
[scrollView
setContentSize:bigRect.size]; // Unknown receiver "scrollView"; should it be "UIScrollView"?
BOOL success = [view becomeFirstResponder];
if (success) {
NSLog(@"HypnosisView became the first responder");
} else {
NSLog(@"Could not become the first responder");
}
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return view;
}
@end
HypnosisView.h
#import <Foundation/Foundation.h>
@interface HypnosisView : UIView {
}
@property(nonatomic,strong)UIColor *circleColor;
@end