2013-11-09 77 views
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 

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

回答

1

我认为你只能将它粘贴到模拟器中 - 用textfield打开一些应用程序,并长按textfield。 Tap paste

+0

我已经有了。多次。现在它最终粘贴视图控制器的整个代码。有任何想法吗? – PanicDev