iphone - 从不工作的 UIButton 创建切换?

标签 iphone ios button toggle

大家好!

基本上,我正在尝试从我的 UIButton 中创建一个简单的切换。使用下面的代码,我可以单击该按钮,但只有一小会儿我会看到@"Expense"作为标题。这可能是一个非常简单的错误。感谢您的帮助!

- (IBAction)typeChanger {
if ([typeButton.titleLabel.text isEqual:@"Income"]) {
    typeButton.titleLabel.text = @"Expense";
}else if ([typeButton.titleLabel.text isEqual:@"Expense"]) {
    typeButton.titleLabel.text = @"Income";
}
}

提前致谢!

最佳答案

这样做,

- (IBAction)typeChanger {
if ([typeButton.titleLabel.text isEqual:@"Income"]) {
   [typeButton setTitle:@"Expense" forState:UIControlStateNormal];
}else if ([typeButton.titleLabel.text isEqual:@"Expense"]) {
    [typeButton setTitle:@"Income" forState:UIControlStateNormal];
}
}

关于iphone - 从不工作的 UIButton 创建切换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15081352/

相关文章:

android - 如何检测 "Recent Apps"系统按钮点击(Honeycomb+)

ruby - 在 Sinatra 中,提供 iPhone 布局与普通布局的最佳方式是什么?

iphone - UIImagePickerController 预览时没有覆盖

ios - 在 Storyboard Xcode 6 中包装几个元素

iOS Facebook SDK : gender being localized

ios - UITableView 多选、预选项

ios - 模态 UINavigationController - 我无法停止旋转

iphone - 如何在导航栏中移动栏按钮项

Android:标准 'Next' 按钮和背景

javascript - 为什么在keydown回调中返回false并不会停止按钮点击事件?