【发布时间】:2016-09-17 08:27:51
【问题描述】:
我正在从同一屏幕上的两个不同按钮对同一视图控制器执行 segue,因此使用相同的 segue 标识符。说按钮是 B1 和 B2。因此,当我从 B1 的 segue 执行 segue 时,我希望目标视图控制器禁用用户交互,但是当我从 B2 进行 segue 时,我希望目标视图控制器是可点击的,并且它的文本字段是可编辑的。请帮我实现它。在这里...考虑 B2 被部分压制和 B1 被 toplbl 并请帮助我使用此代码实现它,所以建议我可以在这里进行更改。
@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(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
{
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()
}
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: 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 ..你能给我完整的功能吗?我需要为此传递额外的对象吗?
标签: ios swift xcode segue uistoryboardsegue