Я создаю приложение для iPad, используя XCode версии 4.3.2. Мне трудно понять, как закрыть всплывающее окно, созданное в раскадровке.
На главном экране у меня есть кнопка. На раскадровке у меня есть переход от этой кнопки к моему всплывающему меню. Мой поповер - это контроллер табличного представления. После выбора элемента в представлении таблицы всплывающих окон я отправляю выбранную информацию обратно родителю и пытаюсь закрыть всплывающее окно. Все работает, за исключением того, что я не могу закрыть всплывающее окно.
Код главного экрана .m файла:
#import "SectionViewController.h"
#import "SortByTableViewController.h"
@interface SectionViewController () <SortByTableViewControllerDelegate>
@end
@implementation SectionViewController
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"DisplaySortByOptions"])
{
SortByTableViewController *popup = (SortByTableViewController*)segue.destinationViewController;
popup.selectedSection = self.selectedSection;
popup.receivedOption = self.selectedItemCharacteristic;
popup.delegate = self;
}
}
- (void)sortByTableViewController:(SortByTableViewController *)sender
returnedOption:(ItemCharacteristic *)returnedOption
{
if(!returnedOption)
{
[self.sortByButton setTitle:@"SHOW ALL" forState:UIControlStateNormal];
}
else
{
[self.sortByButton setTitle:returnedOption.name forState:UIControlStateNormal];
}
self.itemCharacteristic = returnedOption;
[self dismissViewControllerAnimated:YES completion:nil]; //THIS DOES NOT CLOSE THE POPOVER
}
Код файла popover .h:
#import <UIKit/UIKit.h>
@class SortByTableViewController;
@protocol SortByTableViewControllerDelegate <NSObject>
- (void)sortByTableViewController:(sortByTableViewController *)sender
returnedOption:(ItemCharacteristic *)returnedOption;
@end
@interface SortByTableViewController : UITableViewController
@property (nonatomic, strong) Section *selectedSection;
@property (nonatomic, strong) ItemCharacteristic *receivedOption;
@property (nonatomic, weak) id <SortByTableViewControllerDelegate> delegate;
@end
Код файла popover .m:
#import "SortByTableViewController.h"
@interface SortByTableViewController () <UITableViewDelegate>
@end
@implementation SortByTableViewController
@synthesize selectedSection = _selectedSection;
@synthesize receivedOption = _receivedOption;
@synthesize delegate = _delegate;
...
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
ItemCharacteristic *itemCharacteristic = [self.fetchedResultsController objectAtIndexPath:indexPath];
[self.delegate sortByTableViewController:self returnedOption:itemCharacteristic];
[self dismissViewControllerAnimated:YES completion:nil]; //THIS DOESN'T WORK
[self.navigationController popViewControllerAnimated:YES]; //THIS DOESN'T WORK EITHER
}
@end
Спасибо за любую помощь или руководство.