【发布时间】:2014-02-20 09:11:53
【问题描述】:
我正在尝试制作一个常见问题解答,因此当您单击一个按钮时,它会将文本替换为问题和答案。我正在使用此代码替换文本:
ViewContoller.m
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIButton *buttonTest;
- (IBAction)ButtonTest:(id)sender;
@end
ViewController.h
- (IBAction)ButtonTest:(id)sender
{
if ([_buttonTest.titleLabel.text isEqualToString:@"This is the Question No1?"])
{
[sender setTitle:@"This is the Question No1? This is question No1 answer that enter code herehas a fair bit of content" forState:UIControlStateNormal];
}
else
{
[sender setTitle:@"What age is This is the Question No1?" forState:UIControlStateNormal];
}
}
点击按钮后一切正常,但文本显示在第二个问题的顶部。
有谁知道如何让这个移动来适应答案,然后在再次点击它时备份?
谢谢
【问题讨论】:
标签: ios objective-c