如题。。。小白学IPHONE 开发,
linke了两个text fild一个button,一个label,想要实现讲两个text field中输入的字符串合并为一个,点一下button就会显示在lable中
附上代码:
@interface HWViewController ()
@property (strong, nonatomic) IBOutlet UILabel *combinedWord;
@property (strong, nonatomic) IBOutlet UITextField *secondText;
@property (strong, nonatomic) IBOutlet UITextField *firstText;
@property (strong, nonatomic) IBOutlet UIButton *combineButton;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.combinedWord.text=@"Wating...";
}
- (IBAction)myButtonPressed:(id)sender {
NSString *combinedWord= textfiled1+textfield2
求高手回答,想自己做一个project来学习,看了document感觉还是不太会,Q
NSString *combinedWord= [firstText.text stringByAppendingString:secondText.text];
atau
NSString *combinedWord= [NSString stringWithFormat:@"%@%@",firstText.text,secondText.text];
stringByAppendingString
digunakan untuk menggabungkan rentetanstringDenganFormat