J'utilise UIPasteboard
pour copier/coller du texte entre deux UITextView
.Comment effacer/vider le tableau sur viewWillDisappear
code ressemble à ceci:
- (void)viewDidLoad {
[super viewDidLoad];
pasteBoard = [UIPasteboard generalPasteboard]; //it is declared in .h as UIPasteboard *pasteBoard;
}
-(IBAction)doCopyBtn {
if (![toCopyTextView.text isEqualToString:@""]){
pasteBoard.string = toCopyTextView.text;
NSLog(@"pasteb1 %@", pasteBoard.string);
} else {
NSLog (@"error! enter smth");
}
}
-(IBAction)doPasteBtn {
if (![pasteBoard.string isEqualToString:@""]){
toPasteTextView.text = pasteBoard.string;
NSLog(@"pasteb2 %@", pasteBoard.string);
} else {
NSLog (@"error! enter smth");
}
}
Et même cette aide cative (NSLog retourne: pasteb2 (null)
)
-(void) viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[pasteBoard setString:@""];
}
Merci beaucoup! –
Merci pour votre réponse. Si quelqu'un veut une seule longue ligne moche: '[[UIPasteboard generalPasteboard] setValue: @" "pourPasteboardType: UIPasteboardNameGeneral];' –