Display list of default ringtones in iOS

后端 未结 2 1383
逝去的感伤
逝去的感伤 2021-02-03 15:36

I just want to show the list of default ringtones to allow the user select one to set as ringtone for a new notification. Is that possible?

2条回答
  •  面向向阳花
    2021-02-03 16:36

    #import 
    
    - (IBAction) AddMusicOrShowMusic: (id) sender
    {
        MPMediaPickerController *picker =
        [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeMusic];
        picker.delegate = self;
        picker.allowsPickingMultipleItems   = NO;
        picker.prompt                       = NSLocalizedString (@"Add songs to play", "Prompt in media item picker");
        [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault animated: YES];
        [self presentViewController:picker animated:YES completion:NULL];
        [picker release];
    }
    
    - (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) mediaItemCollection
    {
        [self dismissViewControllerAnimated:YES completion:nil];
        item = [[mediaItemCollection items] objectAtIndex:0];
           NSURL *url = [item valueForProperty:MPMediaItemPropertyAssetURL];
        NSLog(@"url : %@",url);
    }
    - (void) mediaPickerDidCancel: (MPMediaPickerController *) mediaPicker
    {
        [self dismissViewControllerAnimated:YES completion:nil];
        [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque animated: YES];
    }
    

提交回复
热议问题