我想提出一個FAQ,所以當你點擊一個按鈕時,它會用問題和答案替換文本。我正在使用此代碼來替換文本:如何使按鈕相對於彼此的位置?
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];
}
}
當單擊按鈕時,它一切正常,但文本顯示在第二個問題的頂部。
有誰知道如何讓這個下移來適應答案,但當它再次點擊時備份?
感謝
我基本上我的列表中顯示的是這樣的: 問題1? 問題2? 問題3? 問題4? 然後當你點擊是顯示問題之間的答案: 問題1? 這是問題1的答案,根據答案的不同文本行! 問題2? 問題3? 問題4? 然後當你再次點擊該按鈕時,它會顯示回原來的列表! 謝謝 – user3255316
對不起,問題列表應該連續顯示! – user3255316