Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode 剪贴板工作吗?_Xcode_String_Copy_Paste - Fatal编程技术网

Xcode 剪贴板工作吗?

Xcode 剪贴板工作吗?,xcode,string,copy,paste,Xcode,String,Copy,Paste,我有一个简单的项目,其中我有几个NSString组合成一个。然后,该字符串被复制到剪贴板。代码如下: #import "CopyToClipViewController.h" @interface CopyToClipViewController () @end @implementation CopyToClipViewController @synthesize device; - (id)initWithNibName:(NSString *)nibNameOrNil bundl

我有一个简单的项目,其中我有几个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

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

我想你只能在模拟器中粘贴它,打开一些带有textfield的应用程序,然后长按textfield。点击粘贴

我已经有了。很多次。现在,它将粘贴视图控制器的全部代码。有什么想法吗?