菜鸟教程小白 发表于 2022-12-12 19:03:36

ios - 继承 UIActionSheet


                                            <p><p>我想继承 <code>UIActionSheet</code> 以便我可以添加 blockAPI。 </p>

<p>我想子类化,这样我仍然可以享受操作表的“ self 保留”行为。<br/>
我更喜欢它而不是创建一个将 <code>UIActionSheet</code> 作为实例保存的对象,因为那样我将需要保存对该对象的引用,因此它不会被释放。 </p>

<p><strong>所以我的问题是,我可以继承 <code>UIActionSheet</code>(Apple 会允许吗)?</strong> </p>

<p>我只是不确定,因为我在 <code>UIActionSheet</code> 类引用中看到:</p>

<blockquote>
<p>Subclassing Notes:<br/>
   UIActionSheet is not designed to be subclassed, nor
should you add views to its hierarchy. If you need to present a sheet
with more customization than provided by the UIActionSheet API, you
can create your own and present it modally with
presentViewController:animated:completion:.</p>
</blockquote></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>答案是否定的。如果您将 UIActionSheet 子类化,您的应用程序在发送到 Apple App Store 时可能会被拒绝。如果 UIActionSheet 不能满足您的需求,您需要实现自己的自定义操作表。这同样适用于 UIAlertView。</p>

<p>这显然是 <strong> <a href="https://developer.apple.com/library/ios/documentation/uikit/reference/UIActionSheet_Class/Reference/Reference.html" rel="noreferrer noopener nofollow">stated in the documentation</a> </strong>:</p>

<blockquote>
<p>UIActionSheet is not designed to be subclassed, nor should you add views to its hierarchy. If you need to present a sheet with more customization than provided by the UIActionSheet API, you can create your own and present it modally with <code>presentViewController:animated:completion:</code>.</p>
</blockquote></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 继承 UIActionSheet,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/21884520/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/21884520/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 继承 UIActionSheet