【发布时间】:2014-03-03 08:58:51
【问题描述】:
我是开发 iOS 应用程序的初学者。我正在关注一些教程。只需在按下 UIButton 后尝试将 UILabel 的文本写入 UITextField 的文本。我已经将 UILabel 和 UITextField 连接到 View Controller(在故事板上,在左侧黄色 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
感谢您的帮助..
【问题讨论】:
-
UILabel 中的文字是怎么设置的?
-
您是否将您的按钮与您的函数 islem: 链接在一起?如果没有,请像对标签和文本字段所做的那样执行此操作,除了从连接出口更改为连接操作。你也可以在你的函数中放置一个断点(点击左边的小边距,你会看到一个蓝色箭头)如果你的应用程序转到这里它会停止...
-
我还没有链接按钮动作 islem,现在它可以工作了。谢谢你..
标签: ios xcode uibutton uitextfield uilabel