开发者

UIButton losing text label when navController returns

I have a custom UIButton that has the label "Name". When the user clicks this button, it loads another View that displays a list of names, and tapping a name pops this View off, and updates the UIButton with the selected name.

That part works. What doesn't work is if the user doesn't select a name from the View, but instead just hits Back. The view is popped off, but now the UIButton text "Name" is removed, and the button text is completely blank. How do I stop the text label from being erased?

I don't have开发者_如何学C any code that updates the UIButton label except if a row is tapped (didSelectARowAtIndexPath) so I don't understand how the label "Name" is being cleared upon loading a new View. Note that I have three of these buttons w/similar functionality, and only the text of the respective button is erased when tapped - the other two aren't impacted.


Are you calling Button.titleLabel.text = @"Name"; or the non dot property version of that. If so that's your problem. You need to call
[Button setTitle:@"Name" forState:UIControlStateNormal]; otherwise the title will be lost when the button changes state. If thats not your issue then please post some code.


Set a breakpoint in your didSelectARowAtIndexPath method and see where it is being called from. You can read Apple's Debugging Applications document for more on using XCode's debugger, or you can just google for "xcode debugging tutorial".

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜