0

我有一个简单的项目,我将几个 NSString 组合成一个。然后,将该字符串复制到剪贴板。这是代码:

#import "CopyToClipViewController.h"

@interface CopyToClipViewController ()

@end

@implementation CopyToClipViewController
@synthesize device;


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    if (self.device) {
        NSString *namevalue;
        NSString *versionvalue;
        NSString *companyvalue;
        namevalue = [self.device valueForKey:@"name"];
        versionvalue = [self.device valueForKey:@"version"];
        companyvalue = [self.device valueForKey:@"company"];

        NSString *shareString = [NSString stringWithFormat:@"I have performed %@ minutes of %@ %@",namevalue, versionvalue, companyvalue];

        UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
        pasteboard.string = shareString;
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

但是,在模拟器中构建并运行项目后,我似乎无法将字符串粘贴到任何其他应用程序中。问题是什么?提前致谢!

4

1 回答 1

1

我认为您只能将其粘贴在模拟器中 - 打开一些带有文本字段的应用程序并长按文本字段。点击粘贴

于 2013-11-09T19:26:03.713 回答