2015-06-30 24 views
0

我有一個UITextField需要在其正確的視圖中顯示一個按鈕。在uitextfield中使用UITableViewCellAccessoryDe​​tailButton

如何加載一個按鈕,其圖像與UITableViewCellAccessoryDe​​tailButton中使用的信息圖標相同?

+0

你必須創建你自己的圖像,看起來像你想要的。 – rmaddy

+0

在屬性檢查器中拖入UIButton並將其類型選擇爲Detail Disclosure。 –

+0

我不是ussing xib或storyboard,@RoryMcKinnel – Matias

回答

0

正如羅裏McKinnel在評論中解釋說,解決的辦法是:

UIButton *button=[UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
0

//說這是你的文本字段

UITextField *txt = [[UITextField alloc]init]; 

//這是你如何添加信息按鈕

UIButton *yourButton = UIButton *button=[UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
[yourButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside]; 
txt.rightView = yourButton; 
txt.rightViewMode = UITextFieldViewModeAlways; 
[self.view addSubview:txt]; 
相關問題