我有一个viewController
调用AudioViewController
。在这方面,我有这个方法:从类方法访问UINavigationController
- (IBAction)stopAction:(id)sender
{
[self.audioClass stop];
}
我有一个NSObject
类叫做AudioClass
。在
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger) buttonIndex
-(void) stop
{
if (!recorder.recording)
{
[player stop];
player.currentTime = 0;
[self.recordOrPauseButton setEnabled:YES];
[self.stopButton setEnabled:NO];
[self alertMessage];
}
else
{
[recorder stop];
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setActive:NO error:nil];
[self alertMessage];
}
}
-(void) alertMessage
{
UIAlertView *stopAlert = [[UIAlertView alloc] initWithTitle: @"Done!"
message: @"Do you want to save it?"
delegate: self
cancelButtonTitle:@"Cancle"
otherButtonTitles:@"Save", nil];
[stopAlert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger) buttonIndex
{
if (buttonIndex == 0)
{
// this is the cancel button
}
else
{
[self.sqLiteDB insertDataIntoTable:soundFilePath And:outputFileURL];
[self.navigationController popViewControllerAnimated:YES];
}
}
现在,这是不承认的
[self.navigationController popViewControllerAnimated:YES];
:在这方面,我有这些方法。
因为,它在NSObject
类中。我如何访问navigationController
并从AudioViewControlelr
返回到之前的ViewController
?
如果任何人有任何解决方案,请与我分享。提前致谢。祝你有美好的一天。
你不能只是在viewController里面移动AlertView逻辑吗? – 2014-11-04 16:04:47
@GonjiDev感谢您的评论。我不能那样做。因为' - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player成功:(BOOL)flag'这个方法也使用相同的'[self alertMessage]''方法。这是'AudioClass'中。 – Tulon 2014-11-04 16:46:30
以下@CleverError回答你应该通知viewController当 - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)播放器成功:(BOOL)flag'被调用。你可以通过各种方式实现这一点,可以使用NSNotificationCenter。显示警报是viewControllers的责任。 – 2014-11-04 16:53:40