iOS NavController 标题问题
目前,我的不同视图的所有标题都正确呈现:
self.title = self.viewedCategory.title;
但是,由于数据结构的原因,主根视图没有标题。我试图用这个来修复它:
if (self.viewedCategory.title == Nil) {
self.title = @"Root View Title";
} else {
self.title = self.viewedCategory.title;
}
但这不起作用,我不知道为什么。我还尝试了 '== @""' 认为它可能是一个没有任何字符的字符串,但这也不起作用。
想法?
Currently, all of my titles for different views are being correctly rendered from this:
self.title = self.viewedCategory.title;
However, because of the data structure, there is no title for the main root view. I tried to fix it with this:
if (self.viewedCategory.title == Nil) {
self.title = @"Root View Title";
} else {
self.title = self.viewedCategory.title;
}
But that doesn't work and I'm not sure why. I also tried '== @""' thinking that it might be a string without any chars, but that didn't work either.
Thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
比较字符串的方法是使用 isEqualToString。所以:
但是测试字符串是否为空或 nil 的更好、更方便的方法是:
对于 @"" 和 nil 来说都是如此,因为 [nil length] 返回 0
The way to compare strings is to use isEqualToString. So:
But a better and more convenient way to test if a string is empty or nil is with:
This will be true for @"" and for nil because [nil length] returns 0
要查看 NSString 是否为空,请执行以下操作。
这将返回一个布尔值,即
YES
或NO
。To see if an NSString is empty do this
This will return a bool value as either
YES
orNO
.如果您比较两个字符串,则使用下面的代码
If You Compare Two String that time below code are used