iOS 7 and the MPMediaPicker, why plus? - ios

I've got two strange diverging behaviours between iOS 6 and 7.
I want to present the MPMediaPicker to the end user, allow them to select 1 song, and start playing that back to them.
So, I show them the MPMediaPicker (/not/ multi, and /not/ cloud, if supported).
Two problems:
In iOS6, the first screen in MPMediaPicker shows the songs. In iOS7,
it's the (empty) playlists. How can I force the MPMediaPicker to
show songs as the default first screen? Is this just another example of Apple "knowing best"?
In iOS7 I get a red (+) symbol next to the media items in the list. What
causes that? I haven't been able to turn up any references for that
in google. What is the (+) symbol? It doesn't seem to highlight separately from the line in the table. The native media picker doesn't display this.
Thanks!
-Ken
Our MPMediaPicker code:
- (void)showSongPicker {
// TODO check if iOS 6
MPMediaPickerController* songPicker = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeMusic];
songPicker.delegate = self;
songPicker.allowsPickingMultipleItems = NO;
songPicker.showsCloudItems = NO;
[self presentViewController:songPicker animated:YES completion:nil];
[self presentModalViewController:songPicker animated:YES];
}
#pragma mark MPMediaPickerControllerDelegate
- (void)mediaPicker: (MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection {
MPMediaItem* item = [mediaItemCollection.items objectAtIndex:0];
[self playMediaItem:item];
[self mediaPickerDidCancel:mediaPicker];
}
- (void)mediaPickerDidCancel:(MPMediaPickerController *)mediaPicker {
[self dismissViewControllerAnimated:YES completion:nil];
}

Oh! I do apologise. I'd forgotten to answer this.
Since I didn't get an answer from anyone else (until just now, thanks, lap.felix), I filed it as a technical question with Apple.
Their answer?
There's no programmatic way to affect the behaviour of the picker. If you need to change the behaviour this "drastically", you have to roll your own media picker.
So...yeah...thanks, Apple.
-Ken

The + doesn't mean anything other than "Add this item to the picker selection"

Related

MediaPicker-based iOS app Not Playing All Songs

I've been looking at this tutorial for information on how to locate songs in a user's music library on their iPhone. Everything is working as it's supposed to, except that songs that are purchased but not on the user's phone do not play.
Does anyone know a way to fix this, or know how to test to see if the song is purchased vs installed and then alert the user?
Below is the code I'm using from the tutorial that selects and plays the songs:
/*
* This method is called when the user presses button. It displays a media picker
* screen to the user configured to show only audio files.
*/
- (IBAction)pickSong:(id)sender
{
MPMediaPickerController *picker = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeAnyAudio];
[picker setDelegate:self];
[picker setAllowsPickingMultipleItems: NO];
[self presentViewController:picker animated:YES completion:NULL];
}
#pragma mark - Media Picker Delegate
/*
* This method is called when the user chooses something from the media picker screen. It dismisses the media picker screen
* and plays the selected song.
*/
- (void)mediaPicker:(MPMediaPickerController *) mediaPicker didPickMediaItems:(MPMediaItemCollection *) collection {
// remove the media picker screen
[self dismissViewControllerAnimated:YES completion:NULL];
// grab the first selection (media picker is capable of returning more than one selected item,
// but this app only deals with one song at a time)
MPMediaItem *item = [[collection items] objectAtIndex:0];
// display title of song in a navigation bar
//NSString *title = [item valueForProperty:MPMediaItemPropertyTitle];
//[_navBar.topItem setTitle:title];
// get a URL reference to the selected item
NSURL *url = [item valueForProperty:MPMediaItemPropertyAssetURL];
// pass the URL to playURL:, defined earlier in this file
[self playURL:url];
}

Application tried to present inside popover with transition style other than UIModalTransitionStyleCoverVertical before printing

I am trying to print a txt file from within a iPad 8.x application. So, I have this code:
- (void)onOpenWith:(UIButton *)theButton path:(NSString *)path
{
NSURL *URL = [NSURL fileURLWithPath:path];
if (URL) {
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL];
self.documentInteractionController.delegate = self;
[self.documentInteractionController presentPreviewAnimated:YES];
}
}
#pragma mark - UIDocumentInteractionControllerDelegate
- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller
{
return self;
}
- (UIView *)documentInteractionControllerViewForPreview:(UIDocumentInteractionController *)controller
{
return self.view;
}
- (CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController *)controller
{
return self.view.frame;
}
Now everything is going as expected, I see a preview of the file, then I touch the icon on the top right corner of the screen and I am able to share the document in those applications that can handle it. However, if I touch PRINT I get this error message:
Application tried to present inside popover with transition style
other than UIModalTransitionStyleCoverVertical
and the app crashes. Sure, i understand it, but to which viewcontroller should I apply this transition? I have no control on the popover showing the print dialog...
In iOS 7 (real iPad not simulator) everything works...
Can anybody help me?
Thanks
Fabio
I also came across this issue, and the solution was that I had to build and run my app with Xcode 6 installed.
On my older machine, I have Xcode 5.1.1, and when run from there, this same issue appeared, and some more issues from this view (like cannot dismiss mail controller when opened from the top right corner).

Why is the cancel button in my media picker not working?

I'm a new developer and I'm getting to know music and sound in iOS.
I've managed to make a media picker where the user can select music but when I press the cancel button, nothing happens. This is the method I'm using:
- (void) mediaPickerDidCancel: (MPMediaPickerController *) mediaPicker
{
[self dismissViewControllerAnimated:YES completion:nil];
}
I tried putting an NSLog in it to see if it was actually being called and there was nothing in the console so it's not actually being called at all. Is there a reason and solution that can be concluded with this information? Have I simply missed out something or might have not done something elsewhere?
Any help would be greatly appreciated.
If the code I used for the media picker would be helpful, here it is:
MPMediaPickerController *mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeAnyAudio];
[mediaPicker setDelegate:self];
mediaPicker.prompt = NSLocalizedString(#"text1", "text2");
[self presentViewController:mediaPicker animated:YES completion:nil];
I wonder if you need to do:
- (void) mediaPickerDidCancel: (MPMediaPickerController *) mediaPicker
{
[mediaPicker dismissViewControllerAnimated:YES completion:nil];
}
instead?
Also, set a break point within your "mediaPickerDidCancel" method and just see it the breakpoint even hits when hitting the cancel button in the picker.
In Swift :
func mediaPickerDidCancel(mediaPicker: MPMediaPickerController){
// Dismiss the picker if the user canceled
dismissViewControllerAnimated(true, completion: nil)
}

XCode Not Breaking on Break Points or Logging After Upgrade (4.2 -> 4.3)

NOTE: This issue was related to XCode. The original question is in place, however the title has been updated to reflect the actual problem.
I'm using a table view for form input and I have created a sort of library for adding input fields to my table. Once on the input fields I need is an image capture field that initiates the device camera.
I have declared the interface as follows.
#interface PhotoBlockCell : UITableViewCell &lt UINavigationControllerDelegate, UIImagePickerControllerDelegate >
To initiate image capture, I have a delegate pointing back to the parent view controller that houses my table view. I launch the device camera using a UIImagePickerController as follows.
- (IBAction)addPhoto:(id)sender{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == YES){
if ([sender isKindOfClass:[UIButton class]])
activeButton = (UIButton*)sender;
UIImagePickerController * imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
[self.delegate presentModalViewController:imagePicker animated:YES];
}
}
This launches the device camera without issue, but I can't seem to capture the resulting photo. Adding breakpoints seems to indicate that my didFinishPickingMediaWithInfo never triggers.
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
// button 1
if (activeButton == button1) {
photo1 = [info objectForKey:#"UIImagePickerControllerOriginalImage"];
}
// dismiss the picker
[picker dismissModalViewControllerAnimated:YES];
}
The view controller is being dismissed, however. Any ideas what the issue might be?
Apparently this was working all along and the issue was related to a recent upgrade from XCode 4.2 to 4.3 (I was forced to upgrade today after upgrading my phone to 5.1). It seems some flag internal to my device was preventing breaking/logging while debugging. A manual pause cleared it up.
I followed instructions here to resolve the issue.
Pause the app using the pause button in XCode.
Add a new break point and continue
Continue after breaking at the new break point.

iOS 5 GM: <Error>: More than maximum 5 filtered album lists trying to register. This will fail

I know this thread existed before, but was closed as only appearing in iOS5 beta 6.
By now I have the Golden Master of iOS 5 on my phone and that error still appears.
This is happening when I create a UIImagePickerController with a sourceType of UIImagePickerControllerSourceTypePhotoLibrary more than 5 times. I am, as far as I can tell, creating and releasing the previous UIImagePickerController correctly each time.
Edit: adding code, as requested.
UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
ipc.delegate = self;
ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:ipc animated:YES];
[ipc release];
Later, I call [self dismissModalViewControllerAnimated:YES]; when -imagePickerController:didFinishPickingImage:editingInfo: gets called.
The problem happens in Apple examples, so the best bet is to ignore.
Later, I call [self dismissModalViewControllerAnimated:YES]; when
-imagePickerController:didFinishPickingImage:editingInfo: gets called.
Have you tried to set the delegate of the image picker to nil, in didFinishPickingImage ?
This is not your fault.It may be vary in different version.Apple should solve this issue.Main thing is that you should check for memory leak is important.Thanks
Try this UIImagePickerControllerSourceTypePhotoLibrary Error
I hope it will help
try setting
picker=nil
in the
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self dismissModalViewControllerAnimated:YES];
picker = nil;
}
it works for me......
Try this one, i am sure this is gonna help you;
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self setModalInPopover:YES];
}

Resources