1

这是我使用 Objective C 的第一天,每次触摸按钮时我都会尝试打印空间。非常感谢。

#import "ViewController.h"

@interface ViewController()

@end

@implementation ViewController

@synthesize display = _display;

-(IBAction)trickClicked:(UIButton *)sender{
    NSString *trick = [sender currentTitle];

    UILabel *myDisplay = self.display;
    NSString *currentText = myDisplay.text;
    NSString *newText = [currentText stringByAppendingString:trick];
    myDisplay.text = newText;

}

@end
4

1 回答 1

1

尝试这个:

// NSString *newText = [currentText stringByAppendingString:trick];
NSString *newText = [NSString stringWithFormat: @"%@ %@", currentText, trick];
于 2013-03-16T21:13:20.233 回答