我有2次:对一个视图执行操作,并在另一个视图上执行操作?这可能吗?
- OneViewController
- TwoViewController
TwoViewController具有IBAction为其中播放声音。一旦用户按下TWoViewController上的按钮,我想要一个UILabel,它将出现在OneViewController上,表示声音已播放。
感谢您的帮助
我有2次:对一个视图执行操作,并在另一个视图上执行操作?这可能吗?
TwoViewController具有IBAction为其中播放声音。一旦用户按下TWoViewController上的按钮,我想要一个UILabel,它将出现在OneViewController上,表示声音已播放。
感谢您的帮助
所有你需要做的是一个参考的viewController在另外一个,这样你可以调用它的方法。或者你可以简单地创建一个委托。
一个可能的解决方案是使用notifications。
在播放声音的操作中,向默认通知中心发送通知,指示声音已播放。
[[NSNotificationCenter defaultCenter] postNotificationName:"playSoundNotification"
object:self
userInfo:nil];
当创建OneViewController时,让它注册通知。
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(showPlayedLabel:)
name:"playSoundNotification"
object:nil];
当它收到通知时 - 在showPlayedLabel中: - 显示UILabel。请注意,showPlayedLabel必须遵循适当的签名格式。
- (void) showPlayedLabel:(NSNotification*) aNotification;
你有什么试过的?什么工作?什么没有?你必须更具体。 –