Created
March 2, 2012 03:25
-
-
Save acidlemon/1955332 to your computer and use it in GitHub Desktop.
MPMediaPickerController color hack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.m | |
// mediapicker | |
// | |
#import "ViewController.h" | |
@implementation ViewController | |
- (void)didReceiveMemoryWarning | |
{ | |
[super didReceiveMemoryWarning]; | |
// Release any cached data, images, etc that aren't in use. | |
} | |
- (IBAction) pick:(id)sender { | |
MPMediaPickerController *picker = | |
[[MPMediaPickerController alloc] | |
initWithMediaTypes: MPMediaTypeAnyAudio]; // 1 | |
[picker setDelegate: self]; // 2 | |
[picker setAllowsPickingMultipleItems: YES]; // 3 | |
picker.prompt = | |
NSLocalizedString (@"ネタ曲を選んだら負けだと思っている", | |
"Prompt in media item picker"); | |
[self presentModalViewController: picker animated: YES]; // 4 | |
NSLog(@"\n%@", [[picker view] recursiveDescription]); // secret method | |
// for iOS5 (他のOSは実機でrecursiveDescriptionの結果からUINavigationBarを探してね★) | |
UINavigationBar* bar = [[[[[[[[[[picker.view subviews] objectAtIndex: 0] subviews] objectAtIndex:0] subviews] objectAtIndex:0] subviews] objectAtIndex:0] subviews] objectAtIndex:1]; | |
NSLog(@"\n%@", bar); | |
bar.tintColor = [UIColor colorWithRed:0.8 green:0.2 blue:0.8 alpha:1.0]; | |
[picker release]; | |
} | |
- (void) mediaPicker: (MPMediaPickerController *) mediaPicker | |
didPickMediaItems: (MPMediaItemCollection *) collection { | |
[self dismissModalViewControllerAnimated: YES]; | |
[self updatePlayerQueueWithMediaCollection: collection]; | |
} | |
- (void) mediaPickerDidCancel: (MPMediaPickerController *) mediaPicker { | |
[self dismissModalViewControllerAnimated: YES]; | |
} | |
#pragma mark - View lifecycle | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view, typically from a nib. | |
} | |
- (void)viewDidUnload | |
{ | |
[super viewDidUnload]; | |
// Release any retained subviews of the main view. | |
// e.g. self.myOutlet = nil; | |
} | |
- (void)viewWillAppear:(BOOL)animated | |
{ | |
[super viewWillAppear:animated]; | |
} | |
- (void)viewDidAppear:(BOOL)animated | |
{ | |
[super viewDidAppear:animated]; | |
} | |
- (void)viewWillDisappear:(BOOL)animated | |
{ | |
[super viewWillDisappear:animated]; | |
} | |
- (void)viewDidDisappear:(BOOL)animated | |
{ | |
[super viewDidDisappear:animated]; | |
} | |
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation | |
{ | |
// Return YES for supported orientations | |
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment