I'm making use of UIPopoverPresentationController in order to present a UITableViewController as its contentViewController on an iPad. In the process, I have noticed that the contentViewController i.e UITableViewController is unable to present itself fully, in that the navigation items that it has, are not being shown. The 2 nav items are of type UIBarButtonItem, one for editing the rows of the tableView, and the other for adding a new row.
Here is the code-
-(IBAction)showAssetTypePicker:(UIButton *)sender{
NSLog(@"AssetTypePicker button pressed!!");
assetTypePicker= [[AssetTypePicker alloc] init];
[self.view endEditing:YES];
NSLog(@"current item's assetType- %@",_item.assetType);
[assetTypePicker setItem:_item];
/*Bronze Challenge*/
if ([[UIDevice currentDevice] userInterfaceIdiom]== UIUserInterfaceIdiomPad) {
[assetTypePicker.tableView setDelegate:self];//Setting DetailViewController as UITableView's delegate
assetTypePicker.modalPresentationStyle= UIModalPresentationPopover;
[self presentViewController:assetTypePicker animated:YES completion:nil];
//Configuring the PopoverPresentationController
assetTypePickerPopover= assetTypePicker.popoverPresentationController;
NSLog(@"assetTypePickerPopover- %@",assetTypePickerPopover);
[assetTypePickerPopover setDelegate:self];
assetTypePickerPopover.sourceView= sender;
assetTypePickerPopover.sourceRect= sender.bounds;
assetTypePickerPopover.permittedArrowDirections= UIPopoverArrowDirectionAny;
}
else{//..for iPhone
[self.navigationController pushViewController:assetTypePicker animated:YES];
}
}
In the above code snippet, the AssetTypePicker is a UITableViewController which is to presented on both iPad and iPhone. For the iPhone, I have had it presented straightaway by pushing it onto an existing viewcontroller, and it takes effect when the user taps a UIButton. For the iPad, there is "assetTypePickerPopover" of type UIPopoverPresentationController, that is being used.
The result is a popover that gets presented upon tapping of a UIButton, but without the UIBarButtonItems that constitute the navigation items of the AssetTypePicker.
https://www.dropbox.com/s/5sfpat05m7un2pg/Screenshot%202019-11-03%20at%209.56.56%20PM.png?dl=0
Whereas, on the iPhone, the navigation items are being shown as-
https://www.dropbox.com/s/kjkrvbn7a7htgss/Screenshot%202019-11-07%20at%206.22.40%20PM.png?dl=0
If anyone could advice on how to work through this, i'd be grateful.