我是开发 iOS 应用程序的初学者。我正在关注一些教程。只需在按下 UIButton 后尝试将 UILabel 的文本写入 UITextField 的文本。我已经将 UILabel 和 UITextField 连接到 View Controller (在 Storyboard上,在左侧黄色 View Controller 中)。 甚至从不同的教程中尝试了很多次不同的例子;从来不工作。 (虽然教程 Xcode 版本是 4.0,但我正在运行 Xcode 5.0.2)
这是 .h 文件。
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
{
IBOutlet UILabel *yazi;
IBOutlet UITextField *sonuc;
}
-(IBAction)islem:(UIButton *)sender;
@end
这是 .m 文件
#import "ViewController.h"
@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)islem: (UIButton *)sender
{
NSString *degiskenAdi=[yazi text];
sonuc.text=degiskenAdi;
}
@end
谢谢你的帮助..
最佳答案
您是否检查过您的 IBOutlet 是否已连接到 Nib ?
您应该看到类似这样的内容:http://i.stack.imgur.com/r1O5U.png
关于ios - 无法运行 iOS 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22142379/