我從同一屏幕上的兩個不同按鈕執行segue到相同的視圖控制器,因此使用相同的segue標識符。說按鈕是B1和B2。所以當我從B1從segue執行segue時,我希望目標視圖控制器禁用用戶交互,但是當我從B2中繼續時,我希望目標視圖控制器可以點擊並且其文本字段可以編輯。請幫我實施它。在這裏...考慮B2是部分壓力,B1是toplbl,請幫助我使用此代碼實施它,所以建議我可以在這裏修改。兩個不同的按鈕執行segue到相同的視圖控制器,但希望通過一個按鈕禁用segue的用戶交互
@IBAction func partialPressed(sender: UIButton)
{
let i = self.getIndex(sender.tag)
let j = self.getSection(sender.tag)
let indexarr = ["index":i, "section":j]
if getSection(sender.tag) == 0
{
let arr = getArray(sender.tag)
performSegueWithIdentifier("partialSupplement", sender: arr)
}
else if getSection(sender.tag) == 1
{
let arr = getArray(sender.tag)
performSegueWithIdentifier("PartialPopup", sender: arr)
}
else if getSection(sender.tag) == 2
{
let arr = getArray(sender.tag)
performSegueWithIdentifier("FoodLifestyle", sender: arr)
else if getSection(sender.tag) == 3
{
let arr = getArray(sender.tag)
performSegueWithIdentifier("Food", sender: arr)
else if getSection(sender.tag) == 4
{
let arr = getArray(sender.tag)
performSegueWithIdentifier("Others", sender: arr)
task.resume()
}
}
@IBAction FUNC toplbl(發件人:的UIButton){
let i = self.getIndex(sender.tag)
let j = self.getSection(sender.tag)
let indexarr = ["index":i, "section":j]
if getSection(sender.tag) == 0
{
task.resume()
let arr1 = getArray(sender.tag)
performSegueWithIdentifier("partialSupplement", sender: arr1)
}
else if getSection(sender.tag) == 1
{
let arr1 = getArray(sender.tag)
performSegueWithIdentifier("PartialPopup", sender: arr1)
}
else if getSection(sender.tag) == 2
{
let arr1 = getArray(sender.tag)
performSegueWithIdentifier("FoodLifestyle", sender: arr1)
task.resume()
}
else if getSection(sender.tag) == 3
{
let arr1 = getArray(sender.tag)
performSegueWithIdentifier("Food", sender: arr1)
task.resume()
}
else if getSection(sender.tag) == 4
{
let arr1 = getArray(sender.tag)
performSegueWithIdentifier("Others", sender: arr1)
task.resume()
}
}
倍率FUNC prepareForSegue(SEGUE:UIStoryboardSegue,發件人:AnyObject){
if segue.identifier == "menuviewcontroller"
{
let menuTableViewController = segue.destinationViewController as! MenuViewcontroller
menuTableViewController.transitioningDelegate = menuTransitionManager
menuTransitionManager.delegate = self
// menuTableViewController.customchildcelldataarray = self.customchildcelldataarray
}
if segue.identifier == "PartialPopup"
{
let popupViewController = segue.destinationViewController as! PatialViewController
popupViewController.arr = sender as! CustomcomingupDataWorkOut
//popupViewController.timings_id = popupViewController.arr.timings_id
//menuTransitionManager.delegate = self
// menuTableViewController.customchildcelldataarray = self.customchildcelldataarray
}
if segue.identifier == "partialSupplement"
{
let popupViewController = segue.destinationViewController as! PartialSupplementViewController
var arr = sender as! CustomcomingUpDataSupplements
popupViewController.lifestyletype = arr.supplementName
popupViewController.lifestyleItem = arr.amount + arr.unit
popupViewController.lifestyleQuantity = arr.dosage_main_name
popupViewController.timings_id = arr.timings_id
//popupViewController.arr = sender as! CustomcomingUpDataSupplements
//popupViewController.timings_id = popupViewController.arr.timings_id
//menuTransitionManager.delegate = self
// menuTableViewController.customchildcelldataarray = self.customchildcelldataarray
}
if segue.identifier == "FoodLifestyle"
{
let popupViewController = segue.destinationViewController as! partialFoodViewController
var arr = sender as! CustomcomingUpDataLifeStyle
popupViewController.lifestyletype = arr.lifestyle_name
popupViewController.lifestyleItem = arr.time + " minutes"
popupViewController.lifestyleQuantity = "Time"
popupViewController.timings_id = arr.timings_id
//popupViewController.arr = sender as! CustomcomingupDataWorkOut
//menuTransitionManager.delegate = self
// menuTableViewController.customchildcelldataarray = self.customchildcelldataarray
}
if segue.identifier == "Food"
{
let popupViewController1 = segue.destinationViewController as! FoodViewController
var arr = sender as! CustomcominUpDataFood
print(arr)
popupViewController1.type = arr.food_name
popupViewController1.Item = arr.time
popupViewController1.Quantity = " Amount"
popupViewController1.timings_id = arr.timings_id
//popupViewController.arr = sender as! CustomcomingupDataWorkOut
//menuTransitionManager.delegate = self
// menuTableViewController.customchildcelldataarray = self.customchildcelldataarray
}
//Others
if segue.identifier == "Others"
{
let popupViewController = segue.destinationViewController as! PartialOthersViewController
var arr = sender as! CustomcominUpDataOthers
popupViewController.lifestyletype = arr.others_name
popupViewController.lifestyleItem = arr.time + " minutes"
popupViewController.lifestyleQuantity = "Completion"
popupViewController.timings_id = arr.timings_id
//popupViewController.arr = sender as! CustomcomingupDataWorkOut
//menuTransitionManager.delegate = self
// menuTableViewController.customchildcelldataarray = self.customchildcelldataarray
}
}
在'prepareForSegue'中檢查發件人,並在目標視圖控制器 – Paulw11
@ Paulw11上設置一個屬性..可以給我完整的函數嗎?是否需要傳遞額外的對象? – Rouny