错误:使用未声明的标识符'label'

时间:2015-08-19 14:09:33

标签: ios objective-c xcode6

我在标题.h文件中有@property label但在我的.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

如何摆脱并修复错误?

1 个答案:

答案 0 :(得分:1)

self.label而不是label

[self.view bringSubviewToFront: self.label];