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
然而,當我建立並運行在模擬器項目中,我似乎無法將字符串粘貼到任何其他應用程序。什麼是問題?提前致謝!
我已經有了。多次。現在它最終粘貼視圖控制器的整個代碼。有任何想法嗎? – PanicDev