Home>
About the action of the button added to TableViewCell
After adding TableView and TableViewCell on Storyboard, added buttons and actions to TableViewCell with the following code.
In the next action, I want to change the background of the button. I want to write the button's own settings in code. What should I do?
func tableView (_ tableView: UITableView, cellForRowAt indexPath: IndexPath)->UITableViewCell {
let cell = UITableViewCell (style: .subtitle, reuseIdentifier: "Cell")
let button = UIButton ()
SetUpButton (button)
cell.contentView.addSubview (button)
button.addTarget (self, action: #selector (self.buttonEvent (_:)), for: UIControl.Event.touchUpInside)
}
@objc func buttonEvent (_ sender: UIButton) {
// code to be realized
}
I wrote the following to the code that I want to achieve // above. However, button cannot be inherited.
Code I want to implement@ objc func buttonEvent (_ sender: UIButton) {
button.backgroundColor = UIColor.black
}
If i read other question sites, etc., it seems that you can do it with button definitions other than in TableViewCell.
Sorry for the ugly text.
-
Answer # 1
Related articles
- ios - i want to add a new cell after the last cell when pressing the [tableview] button
- php - send button display after entering required items
- ios - [swift] even if uivisualeffectview is added to uiimageview, subsubview does not take effect
- javascript - i want to get the added element after loading another file
- ios - i want to detect app reselection after unlocking swift iphone
- ios - the position of the label shifts after transition with a custom animation
- i want to activate the button after canceling the javascript submit event
- ios - i want to make a button that can be pressed only once a day
- ios - after shooting with the camera, i want to transition to the next screen without returning to the previous screen once
- ios - i want to operate the map with the swiftui button
- ios - if you press the button in twitter, you will be given the option to handle the image, and you can send or save it
- ios - i want to disable the button when the password is different in swift
- javascript - i want to be able to press the button after passing the form validation
- ios - i want to transition to the top screen when the button in the container view is pressed
- ios - device not added to xcode simulator
- ios - i want to add action to the alert button
- html - pseudo element :: after added characters do not line up side by side
- ios - swift: when i hit the button repeatedly, i want to display the text display time from the last time i press it
- ios - after displaying the values saved in realm in tebleview, i want to sort and retain
- ios - tapping a button in a custom cell changes the button title
Related questions
- ios - [xcode] regarding the screen transition, it became a strange screen display
- ios - i can't see the keyboard in the xcode simulator
- [ios] effect of setting enable bitcode to false
- ios - data of authauth () currentuser? uid cannot be deleted even if the application is deleted
- ios - i want to change the title from the keyboard when i tap annotation in swift
- ios - i want to pass an array containing tuples in swift and userdefaults
- ios - i want to display the initial text value of uitextfield in swiftui
- ios - i want to set the title on the screen with tabbar under navigationcontroller in swift5
- ios - i don't see the xcode simulator
- ios - i want to convert string to date type in swift4
sender
will send information about the button that was pressed,It's just a reference, so if you play with it, the button you press will change.
If it doesn't work, let me know if you see "tappedBtn Honalara" on the console.