I'm new in objective-c, I created a firstcontroller
which play a song: [mysong play]
also create a slider control of volume: mysong.volume=slider.value
It works fine, and I create another view controller remoteController
with a play button and slider to control firstcontroller
to play the song, I can play the song but how can I pass the slider value to control the volume, thank you someone can enlighten me.
The question is not very clearly explained but I'd say you can add a property to your FirstController
class that exposes the volume value. Something like this:
@interface FirstController : ...
{
float _level;
}
@property (nonatomic, assign) float volumeLevel;
@end
@implementation FirstController
@synthesize volumeLevel = _level;
- (id)init {
...
_level = -1;
...
}
- (void)setVolumeLevel:(float)level {
_level = level;
<# update slider volume here #>
}
- (float)volumeLevel {
if (_level < 0) {
/* first access */
_level = <# read the volume from the slider #>
}
return _level;
}
@end
If you show us some actual code we can taylor the answer to your needs.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.