Dans mon code, je veux ouvrir un contrôleur de vue en tant que presentviewcontroller à l'aide de la feuille d'actions. mais quand je clique sur le bouton de la vue de la feuille d'action ne vient pas mais c'est le code s'exécute.PresentViewController ne fonctionne pas sur le bouton de la feuille d'action
Voici le code Invoquer le feuille d'action:
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@""
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Print Full Report",@"Print Only Selected Questions", nil];
//Creating Attributed String with System Font size of 30.0f
NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"Print Options" attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:20.0f] , NSForegroundColorAttributeName : [UIColor grayColor]}];
//Accessing the Alert View Controller property from Action Sheet
UIAlertController *alertController = [actionSheet valueForKey:@"_alertController"];
//Setting Attributed Title property of Alert View Controller
[alertController setValue:attrString forKey:@"_attributedTitle"];
[actionSheet showInView:self.view];
actionSheet.tag = 100;
Et voici le délégué et les méthodes associées:
- (void)actionSheet:(UIActionSheet *)popup clickedButtonAtIndex:(NSInteger)buttonIndex {
// tag 1 = save options. 2 = clear options
switch (buttonIndex) {
case 0:
[popup dismissWithClickedButtonIndex:0 animated:YES];
pdfFlag=1;
[self printReportAction];
break;
case 1:
[popup dismissWithClickedButtonIndex:1 animated:YES];
pdfFlag=2;
[self printReportAction];
break;
}
}
-(void)printReportAction{
[self presentViewController:previewer animated:YES completion:nil];
}
Code formaté pour les normes et la lisibilité. –