獲得的appdelegate值在Appdelegate.h
我在這兩個Appdelegate.h
和Appdelegate.m
文件導入playerviewcontroller
。從視圖 - 控制
@class PlayerViewController;
@property(nonatomic)float volumeDelegate;
在Appdelegate.m
@synthesize volumeDelegate;
- (void)volumeChanged:(NSNotification *)notification
{
volumeDelegate =1.0
PlayerViewController *volumeObject=[[PlayerViewController alloc]init];
[volumeObject setVolumeForAVAudioPlayer];
}
在Playerviewcontroller.h
-(void)setVolumeForAVAudioPlayer;
在Playerviewcontroller.m
@interface PlayerViewController()
{
AppDelegate *appdelegate;
}
-(void)viewDidLoad
{
appdelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
}
-(void)setVolumeForAVAudioPlayer
{
[appdelegate.sharedplayer setVolume:appdelegate.volumeDelegate];
NSLog(@"System Volume in player view: %f",appdelegate.volumeDelegate);
}
當我運行這個我得到volumeDelegate
值爲零如下。在播放器視圖
系統卷:0.000000000
什麼是我做這裏的錯誤