J'ai ce code:IOS: Format NSString
NSString *firstString = [[NSString stringWithFormat:@"%@",stringToWrite] stringByPaddingToLength:40 withString:@" " startingAtIndex:0];
NSString *finallyString = @"";
finallyString = [firstString stringByAppendingString:secondString];
avec ce code, j'ai un formatage de texte de ma chaîne avec deux colonnes, mais quand j'imprime ces cordes avec la méthode AirPrint ils ont perdu cette mise en forme de texte. Pourquoi dans NSLog tout est ok et quand j'imprime dans un papier il a perdu le formatage du texte?
Code de l'impression:
NSMutableString *printHead = [NSMutableString stringWithFormat:@"%@", @"words"];
for (int i = 0; i<myArray.count; i++)
{
[printHead appendFormat:@"\n\n\n"];
NSString *stringToWrite = [[myArray objectAtIndex:i]objectAtIndex:0];
NSString *firstString = [[NSString stringWithFormat:@"%@",stringToWrite] stringByPaddingToLength:40 withString:@" " startingAtIndex:0];
NSString *finallyString = @"";
finallyString = [firstString stringByAppendingString:[[myArray objectAtIndex:i]objectAtIndex:1]];
[printHead appendString:finallyString];
}
UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
pic.delegate = self;
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
pic.printInfo = printInfo;
UISimpleTextPrintFormatter *textFormatter = [[UISimpleTextPrintFormatter alloc] initWithText:printHead];
textFormatter.startPage = 0;
//textFormatter.color = [UIColor redColor];
textFormatter.contentInsets = UIEdgeInsetsMake(30.0, 30.0, 72.0, 72.0); // 1 inch margins
textFormatter.maximumContentWidth = 8 * 72.0;
pic.printFormatter = textFormatter;
[textFormatter release];
pic.showsPageRange = YES;
void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) =
^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
if (!completed && error) {
NSLog(@"Printing could not complete because of error: %@", error);
}
};
[pic presentAnimated:YES completionHandler:completionHandler];
de quelle police est-il en train d'être imprimé? – Mark
quel est le code pour l'impression? peut-être quelque chose manque, il –
ok je changer mon post – CrazyDev