开发者

I know my title view is a UISegmentedControl, Xcode still warns me

开发者 https://www.devze.com 2022-12-24 02:47 出处:网络
I have a UINavigationalController of which I\'ve set the titleView to a UISegmentedControl. Later on, if I do something like.

I have a UINavigationalController of which I've set the titleView to a UISegmentedControl.

Later on, if I do something like.

[self.navigationItem.titleView setEnabled:NO forSegmentAtIndex:0];

I get a warning saying 开发者_JS百科that UIView may not respond to this message. Of course it does and works fine but how do I properly get rid of the warning?


Cast the titleView as a UISegmentedControl:

[(UISegmentedControl *)self.navigationItem.titleView 
                                           setEnabled:NO forSegmentAtIndex:0];


Similar to DyingCactus's suggestion:

UISegmentedControl * segments = self.navigationItem.titleView;
[segments setEnabled:NO forSegmentAtIndex:0];
0

精彩评论

暂无评论...
验证码 换一张
取 消