我有一个ViewController
,其中有两个重叠ContainerViews
。从其中一个子视图我想将标签更改为另一个。
我创建了一个协议:
protocol pickerDelegate {
func changeMainContainer(index:Int)
}
在儿童观点中:
class ChildViewInContainerController: UIViewController, UIPickerViewDelegate {
var delegateStorePicker:storePickerDelegate?
func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
self.delegatePicker?.changeMainContainer(0)
}
}
在主视图中:
class MainViewController: UIViewController, storePickerDelegate {
func changeMainContainer(index:Int) {
switch index {
case 0 :
self.container1.hidden = true
self.container2.hidden = false
case 1:
self.container1.hidden = false
self.container2.hidden = true
default: break;
}
}
}
代码有效,但未调用changeMainContainer函数。
答案 0 :(得分:1)
协议:(注意我改变了符合using (XLWorkbook wb = new XLWorkbook())
{
wb.Worksheets.Add(dt1);
Response.Clear();
Response.Buffer = true;
Response.Charset ="";
Response.ContentType = "application/vnd.openxmlformats- officedocument.spreadsheetml.sheet";
//Response.AddHeader("content-disposition", "attachment;filename=GridView.xlsx");
Response.AddHeader("content-disposition", "attachment;filename=" + filename);
using (MemoryStream MyMemoryStream = new MemoryStream())
{
wb.SaveAs(MyMemoryStream);
MyMemoryStream.WriteTo(Response.OutputStream);
Response.Flush();
Response.End();
}
的协议)
class
ChildView :(将您的委托更改为弱变量)
protocol PickerDelegate: class {
func changeMainContainer(index:Int)
}
主要观点:
class ChildViewInContainerController: UIViewController, UIPickerViewDelegate {
weak var delegateStorePicker: PickerDelegate?
}
使代表弱会阻止强大的参考周期。