문제

I am trying to switch a UIBarButton identifier depending on a state with this code:

if ([musicPlayer playbackState] == MPMusicPlaybackStatePlaying) {
        [playBtn setStyle:UIBarButtonSystemItemPause];
    } else {
        [playBtn setStyle:UIBarButtonSystemItemPlay];
    }

But I get this warning (and it doesn't work)

Implicit conversion from enumeration type 'enum UIBarButtonSystemItem' to different enumeration type 'UIBarButtonItemStyle' (aka 'enum UIBarButtonItemStyle')

도움이 되었습니까?

해결책

You can't change the the button type like that. As the warning suggests you're actually changing the drawing style (plain / bordered ...) but with the wrong enum type.

To update the button, create a new one and throw the old one away.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top