Tôi cần tạo chế độ xem cửa sổ bật lên mới vì neo không hiển thị trong Trình tạo giao diện trong thời gian biên dịch.Buộc popover trên iPhone với UIPopoverPresentationController được tạo lập trình
Theo this post, việc triển khai phương thức ủy quyền sẽ bắt buộc Popover trên iPhone. (vì lý do tôi không hiểu)
Nó hoạt động tốt khi trên một segue như được hiển thị trong bài viết. Nhưng tôi không thể làm điều này để làm việc theo cách không tách biệt. (Popover hiển thị trên iPad)
Xin vui lòng trợ giúp!
Mã này được liệt kê dưới đây:
func showOptions() {
let contentView = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("PasteOption") as NewPasteOptionViewController
contentView.modalPresentationStyle = UIModalPresentationStyle.Popover
contentView.preferredContentSize = CGSizeMake(200.0, 200.0)
presentViewController(contentView, animated: true, completion: nil)
var _popoverPresentationController = contentView.popoverPresentationController!
_popoverPresentationController.delegate = self
_popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirection.Any
_popoverPresentationController.sourceView = view
_popoverPresentationController.sourceRect = self.navigationItem.titleView!.frame
}
// this function below is never called.
func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
return UIModalPresentationStyle.None
}
Ghi chú thêm:
Các trình bày quan điểm điều khiển được trình bày như một tờ dạng phương thức theo quan điểm khác, và gói gọn trong một bộ điều khiển chuyển hướng. Trình điều khiển chế độ xem được trình bày là bộ điều khiển chế độ xem bảng tùy chỉnh.
Bạn là chính xác. Tò mò rằng tài liệu đã đặt tuyên bố đó đầu tiên (mà đoạn mã cụ thể không có đại biểu thiết lập mặc dù) –
Thiết lập đại biểu nên được đặt trước presentViewController, bạn nghĩ gì? – gabbler
Làm thế nào để bạn mong đợi bản trình bày thành công nếu bạn đặt trình điều khiển bản trình bày sau khi trình bày? –