我有一个简单的项目,我将几个NSStrings合并为一个。然后,该字符串被复制到剪贴板。这是代码:
#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
但是,在模拟器中构建并运行项目后,我似乎无法将字符串粘贴到任何其他应用程序中。有什么问题?提前谢谢!
答案 0 :(得分:1)
我认为你只能在模拟器中粘贴它 - 用文本字段打开一些应用程序并长按文本字段。点按粘贴