Error: Use of undeclared identifier 'label'
Error: Use of undeclared identifier 'label'
我的 label
在 header .h 文件中有一个 @property
,但在我的 .m 文件中。我正在尝试这样做 -
[self.view bringSubviewToFront: label];
但后来我得到了他的错误:Use of undeclared identifier 'label'; did you mean '_label'?
这是我的 .m 文件
#import "ViewController.h"
@interface ViewController ()
@property (strong, nonatomic) IBOutlet UIWebView *webView;
@property (weak, nonatomic) IBOutlet UIWebView *webView2;
@end
@implementation ViewController
@synthesize scrollView;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
draw1 = 0;
scrollView.frame = CGRectMake(0, 300, 480, 55);
[scrollView setContentSize:CGSizeMake(480, 55)];
openMenu.frame = CGRectMake(220, 270, 60, 30);
// stuff************************************************************************************************************************
[super viewDidLoad];
UIWebView *webview=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height)];
NSString *url=@"http://test.bithumor.co/test26.php";
NSURL *nsurl=[NSURL URLWithString:url];
NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
[webview loadRequest:nsrequest];
[self.view addSubview:webview];
webview.scrollView.bounces = NO;
// Do any additional setup after loading the view, typically from a nib.
UIWebView *webview2=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height)];
NSString *url2=@"http://google.com";
NSURL *nsurl2=[NSURL URLWithString:url2];
NSURLRequest *nsrequest2=[NSURLRequest requestWithURL:nsurl2];
[webview2 loadRequest:nsrequest2];
webview2.scrollView.bounces = NO;
[self.view bringSubviewToFront:webview];
[self.view bringSubviewToFront: openMenu];
[self.view bringSubviewToFront: scrollView];
[self.view bringSubviewToFront: label];
这是我的 .h 文件
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController{
IBOutlet UIScrollView *scrollView;
IBOutlet UIButton *openMenu;
int draw1;
}
- (IBAction)OpenMenu:(id)sender;
@property (retain, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet UILabel *label;
@end
如何摆脱和修复我的错误?
说 self.label
而不是 label
。
[self.view bringSubviewToFront: self.label];
我的 label
在 header .h 文件中有一个 @property
,但在我的 .m 文件中。我正在尝试这样做 -
[self.view bringSubviewToFront: label];
但后来我得到了他的错误:Use of undeclared identifier 'label'; did you mean '_label'?
这是我的 .m 文件
#import "ViewController.h"
@interface ViewController ()
@property (strong, nonatomic) IBOutlet UIWebView *webView;
@property (weak, nonatomic) IBOutlet UIWebView *webView2;
@end
@implementation ViewController
@synthesize scrollView;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
draw1 = 0;
scrollView.frame = CGRectMake(0, 300, 480, 55);
[scrollView setContentSize:CGSizeMake(480, 55)];
openMenu.frame = CGRectMake(220, 270, 60, 30);
// stuff************************************************************************************************************************
[super viewDidLoad];
UIWebView *webview=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height)];
NSString *url=@"http://test.bithumor.co/test26.php";
NSURL *nsurl=[NSURL URLWithString:url];
NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
[webview loadRequest:nsrequest];
[self.view addSubview:webview];
webview.scrollView.bounces = NO;
// Do any additional setup after loading the view, typically from a nib.
UIWebView *webview2=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height)];
NSString *url2=@"http://google.com";
NSURL *nsurl2=[NSURL URLWithString:url2];
NSURLRequest *nsrequest2=[NSURLRequest requestWithURL:nsurl2];
[webview2 loadRequest:nsrequest2];
webview2.scrollView.bounces = NO;
[self.view bringSubviewToFront:webview];
[self.view bringSubviewToFront: openMenu];
[self.view bringSubviewToFront: scrollView];
[self.view bringSubviewToFront: label];
这是我的 .h 文件
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController{
IBOutlet UIScrollView *scrollView;
IBOutlet UIButton *openMenu;
int draw1;
}
- (IBAction)OpenMenu:(id)sender;
@property (retain, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet UILabel *label;
@end
如何摆脱和修复我的错误?
说 self.label
而不是 label
。
[self.view bringSubviewToFront: self.label];