代替init,發送它initWithFrame:(CGRect)消息。好像認爲是存在的,它只是有(0,0,0,0)
這裏框架的代碼:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
ViewController *vc = [[ViewController alloc] init];
[vc.view setBackgroundColor:[UIColor redColor]];
MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:CGRectMake(20, 20, 200, 50)];
[volumeView setShowsVolumeSlider:YES];
[volumeView setShowsRouteButton:YES];
[volumeView sizeToFit];
[vc.view addSubview:volumeView];
UILabel *testLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 50, 200, 50)];
testLabel.text = @"TESTING";
[vc.view addSubview:testLabel];
[self.window setRootViewController:vc];
[self.window makeKeyAndVisible];
[vc viewDidLoad];
return YES;
}
對設備進行測試時,它的工作原理:
我剛剛使用你的代碼,它工作正常。 airplay按鈕顯示出來,並且動作起作用......您是將此添加到tableView還是其他內容? – 2013-05-01 18:34:01