ここでは、テーブルビューに4つのセクションがありますが、最初のセクションではすべてのセルにラジオボタンがあります。それがアクティブなときはいつでも、私は残りの3つのセクションを表示する必要があります、私は残りの最後の3つのセクションを非表示にする必要があります誰も私はこれを実装する方法を助けることができますか?ラジオボタンを使用してテーブルビューのセクションを非表示にする方法は?
@IBAction func selectRadioButton(_ sender: KGRadioButton) {
let chekIndex = self.checkIsRadioSelect.index(of: sender.tag)
if sender.isSelected {
} else{
if(chekIndex == nil){
self.checkIsRadioSelect.removeAll(keepingCapacity: false)
self.checkIsRadioSelect.append(sender.tag)
self.ProductTableView.reloadData()
}
}
}
func numberOfSections(in tableView: UITableView) -> Int{
return 4
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
if (section == 0){
return "PAYMENT INFORMATION"
}
else if (section == 1){
return "ORDER REVIEW"
}
else if (section == 2){
return "PRODUCT"
}
else{
return ""
}
}
func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int){
let header = view as! UITableViewHeaderFooterView
header.textLabel?.textColor = UIColor.gray
header.textLabel?.textAlignment = NSTextAlignment.center
header.textLabel?.font = UIFont(name: "Futura", size: 17)
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if (section == 0){
return paymentmethodsArray.count
}
else if (section == 2) {
return productsDetails.count
}
else{
return 1
}
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat{
if (indexPath.section == 0){
return 44
}
else if (indexPath.section == 1){
return 410
}
else if (indexPath.section == 2){
return 120
}
else{
return 230
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if (indexPath.section == 0){
let paymentcell = tableView.dequeueReusableCell(withIdentifier: "paymentcell",for:indexPath) as! paymentTableViewCell
myActivityIndicator.stopAnimating()
let arr = self.paymentmethodsArray[indexPath.row]
paymentcell.paymentNameLabel.text = arr["name"]as? String
paymentcell.radioButton.tag = indexPath.row
let checkIndex = self.checkIsRadioSelect.index(of: indexPath.row)
if(checkIndex != nil){
paymentcell.radioButton.isSelected = true
}else{
paymentcell.radioButton.isSelected = false
}
return paymentcell
}
else if (indexPath.section == 1){
let shippingAddresscell = tableView.dequeueReusableCell(withIdentifier: "shippingaddresscell",for:indexPath) as! ShippingAddressTableViewCell
shippingAddresscell.nameLabel.text = name
shippingAddresscell.addressLabel.text = billingaddress
shippingAddresscell.mobileNumberLabel.text = String(describing: phoneNumber)
shippingAddresscell.shippingNameLabel.text = name
shippingAddresscell.shippingAddressLabel.text = billingaddress
shippingAddresscell.shippingMobileNumberLabel.text = String(describing: phoneNumber)
shippingAddresscell.shippingMethodNameLabel.text = shippingMethod
shippingAddresscell.paymentMethodNameLabel.text = paymentMethod
return shippingAddresscell
}
else if (indexPath.section == 2){
let productNamecell = tableView.dequeueReusableCell(withIdentifier: "productNamecell",for:indexPath) as! ProductNameTableViewCell
let arr = productsDetails[indexPath.row]
let array = arr["product name"] as! String
productNamecell.productNameLabel.text = array
productNamecell.priceLabel.text = arr["Price"] as! String
productNamecell.QuantityLabel.text = String(describing: arr["Quantity"] as! Int)
productNamecell.subTotalLabel.text = arr["SubTotal"] as! String
return productNamecell
}
else{
let ordercell = tableView.dequeueReusableCell(withIdentifier: "ordercell",for:indexPath) as! orderTableViewCell
ordercell.subTotalLabel.text = subTotal
ordercell.shippingLabel.text = shippingHandling
ordercell.grandTotalLabel.text = total
return ordercell
}
}
複数のラジオボタンを同時に選択できますか? –
一度にアクティブになるのは1つだけです –
アクティブなときはすべてのセクションを表示する必要があります。最初のセクション –