{"id":7613,"date":"2025-06-02T14:00:34","date_gmt":"2025-06-05T06:09:33","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=7613"},"modified":"2025-06-05T14:00:34","modified_gmt":"2025-06-05T06:09:33","slug":"https-badgameshow-com-steven-458","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/swift\/https-badgameshow-com-steven-458\/","title":{"rendered":"Swift \u5f48\u51fa\u8996\u5716\u63a7\u5236\u9805(UIPopoverController) 2025 \u6700\u65b0\u6559\u5b78 \u2013 \u7bc4\u4f8b\u4ee3\u78bc\u8207\u6700\u4f73\u5be6\u8e10"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"swift, UIPopoverController, Swift \u6559\u5b78, iOS \u958b\u767c, \u5f48\u51fa\u8996\u5716\"><\/p>\n<p>Swift \u662f\u4e00\u7a2e\u73fe\u4ee3\u5316\u7684\u7a0b\u5f0f\u8a9e\u8a00\uff0c\u65e8\u5728\u8b93\u958b\u767c\u8005\u80fd\u5920\u5feb\u901f\u800c\u9ad8\u6548\u5730\u958b\u767c\u51fa\u529f\u80fd\u5f37\u5927\u7684\u61c9\u7528\u7a0b\u5f0f\u3002\u5728 Swift \u958b\u767c\u4e2d\uff0c<strong>UIPopoverController<\/strong> \u662f\u4e00\u500b\u975e\u5e38\u5be6\u7528\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u7528\u4f86\u986f\u793a\u5f48\u51fa\u8996\u5716\uff0c\u63d0\u4f9b\u66f4\u8c50\u5bcc\u7684\u4f7f\u7528\u8005\u4e92\u52d5\u9ad4\u9a57\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528 Swift 2025 \u7684\u6700\u65b0\u8a9e\u6cd5\u4f86\u5275\u5efa UIPopoverController\uff0c\u5305\u62ec\u5b8c\u6574\u7684\u5be6\u4f5c\u7bc4\u4f8b\u548c\u6700\u4f73\u5be6\u8e10\uff0c\u8b93\u60a8\u8f15\u9b06\u4e0a\u624b\u3002<\/p>\n<h2>\u4ec0\u9ebc\u662f UIPopoverController\uff1f<\/h2>\n<p><strong>UIPopoverController<\/strong> \u662f\u4e00\u7a2e\u5c08\u9580\u7528\u65bc\u5728 iOS \u61c9\u7528\u7a0b\u5f0f\u4e2d\u986f\u793a\u5f48\u51fa\u8996\u5716\u7684\u63a7\u5236\u9805\u3002\u5b83\u53ef\u4ee5\u7528\u4f86\u5c55\u793a\u4e0d\u540c\u7684\u5167\u5bb9\uff0c\u4f8b\u5982\u641c\u7d22\u6846\u3001\u8a2d\u7f6e\u6309\u9215\u3001\u5de5\u5177\u63d0\u793a\u7b49\uff0c\u63d0\u5347\u7528\u6236\u7684\u64cd\u4f5c\u4fbf\u5229\u6027\u548c\u61c9\u7528\u7a0b\u5f0f\u7684\u6574\u9ad4\u529f\u80fd\u6027\u3002<\/p>\n<h2>\u5982\u4f55\u4f7f\u7528 Swift 2025 \u5275\u5efa UIPopoverController\uff1f<\/h2>\n<p>\u4f7f\u7528 Swift \u4f86\u5275\u5efa <strong>UIPopoverController<\/strong> \u8b8a\u5f97\u66f4\u52a0\u7c21\u55ae\u548c\u76f4\u89c0\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528\u6700\u65b0\u8a9e\u6cd5\u5275\u5efa\u5f48\u51fa\u8996\u5716\u63a7\u5236\u9805\u7684\u6b65\u9a5f\uff1a<\/p>\n<h3>\u6b65\u9a5f 1\uff1a\u521d\u59cb\u5316 UIPopoverController<\/h3>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u5275\u5efa\u4e00\u500b <strong>UIPopoverController<\/strong> \u7269\u4ef6\u4e26\u521d\u59cb\u5316\u5b83\u3002\u4ee5\u4e0b\u662f\u7bc4\u4f8b\u4ee3\u78bc\uff1a<\/p>\n<pre><code class=\"language-swift line-numbers\">let contentViewController = YourContentViewController() \/\/ \u66ff\u63db\u70ba\u60a8\u7684\u8996\u5716\u63a7\u5236\u5668\nlet popoverController = UIPopoverController(contentViewController: contentViewController)\n<\/code><\/pre>\n<h3>\u6b65\u9a5f 2\uff1a\u8a2d\u7f6e\u5f48\u51fa\u8996\u5716\u5927\u5c0f<\/h3>\n<p>\u63a5\u8457\uff0c\u60a8\u9700\u8981\u8a2d\u7f6e\u5f48\u51fa\u8996\u5716\u7684\u5927\u5c0f\uff0c\u4ee5\u9069\u61c9\u5176\u5167\u5bb9\uff1a<\/p>\n<pre><code class=\"language-swift line-numbers\">popoverController.preferredContentSize = CGSize(width: 200, height: 200) \/\/ \u8a2d\u5b9a\u5927\u5c0f\n<\/code><\/pre>\n<h3>\u6b65\u9a5f 3\uff1a\u986f\u793a UIPopoverController<\/h3>\n<p>\u6700\u5f8c\uff0c\u60a8\u53ef\u4ee5\u5f9e\u6307\u5b9a\u7684\u6309\u9215\u6216\u8996\u5716\u986f\u793a\u5f48\u51fa\u8996\u5716\uff1a<\/p>\n<pre><code class=\"language-swift line-numbers\">popoverController.present(from: sender.bounds, in: sender, animated: true, completion: nil) \/\/ sender \u662f\u89f8\u767c\u6309\u9215\n<\/code><\/pre>\n<h2>\u932f\u8aa4\u6392\u9664<\/h2>\n<p>\u5728\u4f7f\u7528 <strong>UIPopoverController<\/strong> \u6642\uff0c\u60a8\u53ef\u80fd\u6703\u9047\u5230\u4e00\u4e9b\u5e38\u898b\u554f\u984c\uff1a<\/p>\n<ul>\n<li><strong>\u554f\u984c\uff1a<\/strong>\u5f48\u51fa\u8996\u5716\u6c92\u6709\u986f\u793a\u3002<\/li>\n<li><strong>\u89e3\u6c7a\u65b9\u6848\uff1a<\/strong>\u78ba\u4fdd <code>sender<\/code> \u662f\u6709\u6548\u7684\u8996\u5716\uff0c\u4e26\u4e14\u5176\u908a\u754c\u8a2d\u7f6e\u6b63\u78ba\u3002<\/li>\n<li><strong>\u554f\u984c\uff1a<\/strong>\u5167\u5bb9\u7121\u6cd5\u5b8c\u6574\u986f\u793a\u3002<\/li>\n<li><strong>\u89e3\u6c7a\u65b9\u6848\uff1a<\/strong>\u6aa2\u67e5 <code>preferredContentSize<\/code> \u662f\u5426\u8a2d\u7f6e\u5f97\u7576\uff0c\u4e26\u78ba\u4fdd\u5167\u5bb9\u8996\u5716\u63a7\u5236\u5668\u7684\u5e03\u5c40\u6b63\u78ba\u3002<\/li>\n<\/ul>\n<h2>\u5ef6\u4f38\u61c9\u7528<\/h2>\n<p>\u60a8\u53ef\u4ee5\u8003\u616e\u5c07 <strong>UIPopoverController<\/strong> \u8207\u5176\u4ed6\u529f\u80fd\u7d50\u5408\u4f7f\u7528\uff0c\u4f8b\u5982\u5728\u5f48\u51fa\u8996\u5716\u4e2d\u52a0\u5165\u8868\u55ae\u3001\u6309\u9215\u6216\u5217\u8868\uff0c\u4ee5\u589e\u5f37\u7528\u6236\u4e92\u52d5\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528 <strong>UITableView<\/strong> \u5728\u5f48\u51fa\u8996\u5716\u4e2d\u986f\u793a\u53ef\u9078\u9805\u76ee\uff0c\u8b93\u7528\u6236\u9032\u884c\u9078\u64c7\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2023\/02\/Swift-\u5f48\u51fa\u8996\u5716\u63a7\u5236\u9805UIPopoverController-\ud83d\udca5\u5b78\u7fd2\u6559\u5b78-\u2013-\u7bc4\u4f8b\u4ee3\u78bc\u8b93\u60a8\u5feb\u901f\u5b78\u7fd2_1675478017.22692.webp\" alt=\"Swift \u5f48\u51fa\u8996\u5716\u63a7\u5236\u9805(UIPopoverController) \ud83d\udca5\u5b78\u7fd2\u6559\u5b78 \u2013 \u7bc4\u4f8b\u4ee3\u78bc\u8b93\u60a8\u5feb\u901f\u5b78\u7fd2\" title=\"Swift UIPopoverController\u3001\u5f48\u51fa\u8996\u5716\u63a7\u5236\u3001\u7bc4\u4f8b\u6559\u5b78\" width=\"1200\" height=\"628\"\/><\/p>\n<h2>Q&#038;A\uff08\u5e38\u898b\u554f\u984c\u89e3\u7b54\uff09<\/h2>\n<h3>1. UIPopoverController \u8207 UIAlertController \u6709\u4ec0\u9ebc\u5340\u5225\uff1f<\/h3>\n<p><strong>UIPopoverController<\/strong> \u7528\u65bc\u986f\u793a\u81ea\u5b9a\u7fa9\u8996\u5716\uff0c\u800c <strong>UIAlertController<\/strong> \u5247\u7528\u65bc\u986f\u793a\u6a19\u6e96\u7684\u8b66\u544a\u548c\u63d0\u793a\u6846\u3002\u5169\u8005\u9069\u7528\u65bc\u4e0d\u540c\u7684\u5834\u666f\u3002<\/p>\n<h3>2. \u53ef\u4ee5\u5728 UIPopoverController \u4e2d\u4f7f\u7528\u52d5\u756b\u6548\u679c\u55ce\uff1f<\/h3>\n<p>\u662f\u7684\uff0c\u60a8\u53ef\u4ee5\u5728\u986f\u793a\u548c\u96b1\u85cf <strong>UIPopoverController<\/strong> \u6642\u4f7f\u7528\u52d5\u756b\uff0c\u9019\u6a23\u53ef\u4ee5\u63d0\u5347\u7528\u6236\u9ad4\u9a57\u3002<\/p>\n<h3>3. UIPopoverController \u5728 iPad \u548c iPhone \u4e0a\u7684\u884c\u70ba\u6709\u4f55\u4e0d\u540c\uff1f<\/h3>\n<p>\u5728 iPad \u4e0a\uff0c<strong>UIPopoverController<\/strong> \u901a\u5e38\u986f\u793a\u70ba\u5f48\u51fa\u8996\u5716\uff0c\u800c\u5728 iPhone \u4e0a\u5247\u6703\u5168\u5c4f\u986f\u793a\uff0c\u9019\u662f\u7531\u65bc\u5c4f\u5e55\u5c3a\u5bf8\u7684\u9650\u5236\u6240\u81f4\u3002<\/p>\n<p>\u900f\u904e\u9019\u7bc7\u6587\u7ae0\uff0c\u60a8\u61c9\u8a72\u5c0d\u5982\u4f55\u4f7f\u7528 Swift 2025 \u4f86\u5275\u5efa <strong>UIPopoverController<\/strong> \u6709\u4e86\u66f4\u6df1\u5165\u7684\u4e86\u89e3\uff0c\u4e26\u80fd\u5920\u61c9\u7528\u65bc\u60a8\u7684 iOS \u958b\u767c\u9805\u76ee\u4e2d\u3002\u671f\u5f85\u60a8\u5728\u958b\u767c\u904e\u7a0b\u4e2d\u80fd\u5920\u767c\u63ee\u5275\u610f\uff0c\u5275\u9020\u51fa\u66f4\u512a\u79c0\u7684\u61c9\u7528\u7a0b\u5f0f\uff01<\/p>\n<p>&#8212;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6458\u8981\uff1a\u672c\u6587\u5c07\u4ecb\u7d39Swift\u4e2dUIPopoverController\u7684\u7bc4\u4f8b\u6559\u5b78\uff0c\u8b93\u60a8\u5feb\u901f\u5b78\u7fd2\u5982\u4f55\u4f7f\u7528UIPopoverController\u4f86\u63a7\u5236\u5f48\u51fa\u8996\u5716\uff0c\u4e26\u63d0\u4f9b\u7bc4\u4f8b\u4ee3\u78bc\u4f9b\u53c3\u8003\u3002<\/p>\n","protected":false},"author":1,"featured_media":7612,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[174,5],"tags":[173,9],"class_list":["post-7613","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ios","category-swift","tag-ios","tag-swift"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2023\/02\/Swift-\u5f48\u51fa\u8996\u5716\u63a7\u5236\u9805UIPopoverController-\ud83d\udca5\u5b78\u7fd2\u6559\u5b78-\u2013-\u7bc4\u4f8b\u4ee3\u78bc\u8b93\u60a8\u5feb\u901f\u5b78\u7fd2_1675478017.22692.webp","jetpack-related-posts":[],"jetpack_shortlink":"https:\/\/wp.me\/pcFK27-1YN","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/7613","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/comments?post=7613"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/7613\/revisions"}],"predecessor-version":[{"id":13234,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/7613\/revisions\/13234"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media\/7612"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=7613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=7613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=7613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}