私はObjective -Cを使い始めたばかりです。私のコードはエラーを出し続けます: プロパティ 'view' がフォワード クラス オブジェクト 'startPageViewController' に見つかりません。私はそれが何であるかを解決することはできません! これが私のコードです。
startPageViewController.h -
#import <UIKit/UIKit.h>
@class searchResultsViewController;
@class startPageViewController;
@interface startPageViewController : UIViewController
- (IBAction)switchViews:(id)sender;
@property (strong, nonatomic) IBOutlet UITextField * searchterm;
@property (nonatomic, retain) startPageViewController *blueViewController;
@property (nonatomic, retain) searchResultsViewController *yellowViewController;
@end
startPageViewController.m -
#import "startPageViewController.h"
#import "searchResultsViewController.h"
@class searchResultsViewController;
@class startPageViewController;
@interface startPageViewController ()
@end
@implementation startPageViewController
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (IBAction)switchViews:(id)sender {
[self.view removeFromSuperview]; // <-- Error here
[self.view insertSubview:_yellowViewController.view atIndex:0];
}
- (void)viewDidUnload {
[self setSearchterm:nil];
[super viewDidUnload];
}
@end
searchResultsViewController.h -
#import <UIKit/UIKit.h>
@interface searchResultsViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIWebView *googleResults;
@property (strong, nonatomic) IBOutlet UIWebView *bingResults;
@property (strong, nonatomic) IBOutlet UIWebView *amazonResults;
@property (strong, nonatomic) IBOutlet UIWebView *ebayResults;
@end
searchResultsViewController.m -
#import "searchResultsViewController.h"
@interface searchResultsViewController ()
@end
@implementation searchResultsViewController
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *googleUrlAddress = @"http://www.google.com/";
NSURL *googleUrl = [NSURL URLWithString:googleUrlAddress];
NSURLRequest *googleRequestObj = [NSURLRequest requestWithURL:googleUrl];
[_googleResults loadRequest:googleRequestObj];
// --------------------
NSString *bingUrlAddress = @"http://www.bing.com/";
NSURL *bingUrl = [NSURL URLWithString:bingUrlAddress];
NSURLRequest *bingRequestObj = [NSURLRequest requestWithURL:bingUrl];
[_bingResults loadRequest:bingRequestObj];
// --------------------
NSString *amazonUrlAddress = @"http://www.amazon.com/";
NSURL *amazonUrl = [NSURL URLWithString:amazonUrlAddress];
NSURLRequest *amazonRequestObj = [NSURLRequest requestWithURL:amazonUrl];
[_amazonResults loadRequest:amazonRequestObj];
// --------------------
NSString *ebayUrlAddress = @"http://www.ebay.com/";
NSURL *ebayUrl = [NSURL URLWithString:ebayUrlAddress];
NSURLRequest *ebayRequestObj = [NSURLRequest requestWithURL:ebayUrl];
[_ebayResults loadRequest:ebayRequestObj];
}
- (void)viewDidUnload {
[self setGoogleResults:nil];
[self setBingResults:nil];
[self setAmazonResults:nil];
[self setEbayResults:nil];
[super viewDidUnload];
}
@end
前もって感謝します!
ところで、複雑すぎることは何もありません。私はまだ12歳です。:)