【发布时间】:2013-05-20 06:06:21
【问题描述】:
我是 iOS 新手。我在这里搜索了 UITextfield Sematic Issues,以及它的变体。我正在尝试制作一个非常简单的应用程序,你:
在文本字段中输入文本 按按钮 它将标签更改为在文本字段中输入的文本。
但我不断收到这个奇怪的语义错误,我不知道如何解决它。
代码在这里:
.m 文件。
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *myTextField;
@property (weak, nonatomic) IBOutlet UILabel *myLabel;
- (IBAction)changeLabel:(id)sender;
@end
.h
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)changeLabel:(id)sender {
NSString *message = [[NSString alloc] initWithFormat:@"Hello %@", [myTextField text]];
[myLabel setText:message];
}
谢谢。
【问题讨论】:
-
您遇到了什么编译器错误?请张贴。
-
我实现了你的代码,它工作正常.....你的错误是什么
-
@AhmedZ。你的说法不正确。 Objective C 允许使用这种语法访问属性和方法。
标签: ios compiler-errors uilabel semantics