这是我的第一个问题。我正在尝试制作一个可与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