2015-04-29 15 views
10

Tôi có một mục nút thanh trong thanh điều hướng khi được nhấn, sẽ trình bày một UIAlertController với kiểu là .ActionSheet. Trong iPhone nó chỉ xuất hiện theo cách mà tôi muốn. Đối với iPad Tôi biết tôi cần phải thêmActionSheet Source View BarButtonItem

// For iPad, set the pop over bounds 
var popOver = optionMenu.popoverPresentationController 
popOver?.sourceView = button as UIView 
popOver?.sourceRect = (button as UIView).bounds 
popOver?.permittedArrowDirections = UIPopoverArrowDirection.Any 

Có ai biết một cách sử dụng nút mục thanh như sourceViewsourceRect? Tôi muốn cửa sổ bật lên trỏ đến mục nút thanh.

Trả lời

25

Chỉ cần sử dụng popOver?.barButtonItem = myBarButtonItem

+0

HOÀN THÀNH! Cảm ơn tôi không thấy làm thế nào tôi bỏ lỡ điều đó. –