Tôi đã tìm thấy một câu hỏi tương tự nhất với tôi tuy nhiên nó không được trả lời kỹ lưỡng. Sẽ rất tuyệt nếu có ai có thể giúp tôi. Nơi tôi tìm thấy câu hỏi tương tự là here.Nhiều Tham số/Đối số cho Hành động - Swift
Tôi hiểu rõ cách thức func test()
sẽ là "test"
và test(object:AnyObject)
sẽ là "test:"
. Cảm ơn this.
Vậy có 2 tham số thì sao? Có thể nhanh chóng không làm 2 đối số cho 'hành động:'?
func popoverSelectedCode (code:AnyObject, desc:AnyObject)
tôi đã cố gắng thử nghiệm nó ra trong vài cách khác nhau dưới đây, nhưng không có kết quả:
action: "popoverSelectedCode:,"
action: "popoverSelectedCode:,:"
action: "popoverSelectedCode: :"
action: "popoverSelectedCode: , :"
Am chỉ khoảng một tuần tuổi trong Swift vì vậy hãy loại.
EDITED Đây là một clip ngắn của mã
@IBAction func securityQuestButtonClicked (sender:AnyObject)
{
cellButton = sender as? UIButton;
var comboDescListArray = TableRoutine.loadCombobox("MobileQuestion")
var codeObject : NSArray = comboDescListArray[0] as NSArray;
var descObject : NSArray = comboDescListArray[1] as NSArray;
var selectionTVC = CPSelectionTVC(style:UITableViewStyle.Plain, codeArray:codeObject, descArray:descObject, target:self, action: "popoverSelectedCode::", widthForViewInPopover:650)
let navCtl = UINavigationController.init(rootViewController:selectionTVC)
popoverController = UIPopoverController.init(contentViewController:navCtl)
var contentHeight : CGFloat = CGFloat (UInt(selectionTVC.navigationTitleHeight) + UInt(selectionTVC.rowCount()) * UInt(selectionTVC.cellHeight))
popoverController?.popoverContentSize = CGSizeMake(400.0, contentHeight)
popoverController?.presentPopoverFromRect(sender.bounds, inView:sender as UIView, permittedArrowDirections:UIPopoverArrowDirection.Up, animated:true)
}
Các popover xuất hiện tuy nhiên khi lựa chọn, nó chỉ bị treo.
Bạn có nhận được câu trả lời không? tôi đang đối phó với cùng một vấn đề. Nếu vậy, bạn đã viết bộ chọn của mình với nhiều tham số như thế nào và chức năng hành động trông như thế nào. cảm ơn. –
Thật không may là không. Tôi đã bận rộn với những thứ khác, nhưng tôi đã dành cả ngày hôm nay cố gắng để tìm kiếm câu trả lời mới. Đừng giữ tôi đăng nếu bạn tình cờ gặp một câu trả lời. –