0
我有一個UITextField需要在其正確的視圖中顯示一個按鈕。在uitextfield中使用UITableViewCellAccessoryDetailButton
如何加載一個按鈕,其圖像與UITableViewCellAccessoryDetailButton中使用的信息圖標相同?
我有一個UITextField需要在其正確的視圖中顯示一個按鈕。在uitextfield中使用UITableViewCellAccessoryDetailButton
如何加載一個按鈕,其圖像與UITableViewCellAccessoryDetailButton中使用的信息圖標相同?
正如羅裏McKinnel在評論中解釋說,解決的辦法是:
UIButton *button=[UIButton buttonWithType:UIButtonTypeDetailDisclosure];
//說這是你的文本字段
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];
你必須創建你自己的圖像,看起來像你想要的。 – rmaddy
在屬性檢查器中拖入UIButton並將其類型選擇爲Detail Disclosure。 –
我不是ussing xib或storyboard,@RoryMcKinnel – Matias