這是我的第一個問題。我正在嘗試製作一個可與Core Audio合作的應用程序。我發現這個框架http://theamazingaudioengine.com/,我試圖使用,到目前爲止,我設法做文檔中的第一件事,即播放文件。但是,通過在應用程序委託中自定義初始化UIViewController,我失去了它的所有內容,並且視圖控制器變黑,沒有其他元素。我的UIViewController只有一個按鈕,我想用它來啓動文件的播放,但由於我無法訪問它,此刻,當項目構建時,文件開始播放。(iOS)自定義初始化時出現黑屏UIViewController
任何想法我做錯了什麼?
這是我的appDelegate:
@implementation SoundCheckAppDelegate
@synthesize window = _window;
@synthesize audioController = _audioController;
@synthesize viewController = _viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Create an instance of the audio controller, set it up and start it running
self.audioController = [[[AEAudioController alloc] initWithAudioDescription:[AEAudioController nonInterleaved16BitStereoAudioDescription] inputEnabled:YES] autorelease];
_audioController.preferredBufferDuration = 0.005;
[_audioController start:NULL];
// Create and display view controller
self.viewController = [[SoundCheckViewController alloc] initWithAudioController:_audioController];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
@end
而且我的UIViewController:
@interface SoundCheckViewController()
@property (nonatomic, strong) AEAudioController *audioController;
@property (nonatomic, strong) AEAudioFilePlayer *loop;
@end
@implementation SoundCheckViewController
- (id)initWithAudioController:(AEAudioController*)audioController {
self.audioController = audioController;
NSError *error;
NSURL *file = [[NSBundle mainBundle] URLForResource:@"Southern Rock Drums" withExtension:@"m4a"];
self.loop = [AEAudioFilePlayer audioFilePlayerWithURL:file
audioController:_audioController
error:&error];
if(error)
NSLog(@"couldn't start loop");
_loop.removeUponFinish = YES;
_loop.loop = YES;
_loop.completionBlock = ^{
self.loop = nil;
};
[_audioController addChannels:[NSArray arrayWithObject:_loop]];
return self;
}
@end
你在哪裏定製你的視圖控制器的視圖? XIB?故事情節? – rdelmar 2013-04-26 16:21:15
它在我的故事板 - xcode給你開始一個項目時給你的那個 – kanstraktar 2013-04-26 16:48:06
它在我的故事板中,我在其中添加按鈕 – kanstraktar 2013-04-26 16:48:53