当自定义视图控制器没有';t直接从UIViewController继承

本文关键字:继承 UIViewController 视图 自定义 控制器 | 更新日期: 2023-09-27 18:29:35

我正在尝试使用Three20的导航部分。为了与Three20程序集接口,我不得不创建一个绑定项目,其中包含绑定到Three20中的类的类。其中之一是对UIKit UIViewController进行了添加的UIViewController。这意味着,如果我要使用基于URL的导航的Three20功能,我的ViewControllers必须从这个类继承。

问题是:

如果我从Three20 UIViewController继承,然后尝试在Xcode中编辑.xib,MonoDevelop不会创建Xcode添加Outlet等所需的.h和.m文件。

有人知道有一种方法可以让View控制器不直接从MonoTouch.UIKit.UIViewcontroller继承,并且可以在Xcode中编辑吗?

这是我的代码:

public partial class TestViewController : TTBaseViewController
{

以及在一个单独的MonoTouch绑定项目中:

[BaseType (typeof (MonoTouch.UIKit.UIViewController))]
interface TTBaseViewController
{   
    /**
     * Displays a controller inside this controller.
     *
     * TTURLMap uses this to display newly created controllers.  The default does nothing --
     * UIViewController categories and subclasses should implement to display the controller
     * in a manner specific to them.
     */
    [Bind("addSubcontroller:animated:transition:")]
    void AddSubcontroller(UIViewController controller, bool animated, UIViewAnimationTransition transition);

它产生了这样的类定义:

[Register("TTBaseViewController", true)]
public partial class TTBaseViewController : MonoTouch.UIKit.UIViewController {
    static IntPtr selAddSubcontrollerAnimatedTransition_ = Selector.GetHandle ("addSubcontroller:animated:transition:");
    static IntPtr selRemoveFromSupercontroller = Selector.GetHandle ("removeFromSupercontroller");
    static IntPtr selRemoveFromSupercontrollerAnimated_ = Selector.GetHandle ("removeFromSupercontrollerAnimated:");
    static IntPtr selKeyForSubcontroller_ = Selector.GetHandle ("keyForSubcontroller:");
    static IntPtr selSubcontrollerForKey_ = Selector.GetHandle ("subcontrollerForKey:");
    static IntPtr selPersistView_ = Selector.GetHandle ("persistView:");
    static IntPtr selRestoreView_ = Selector.GetHandle ("restoreView:");
    static IntPtr selSuperController = Selector.GetHandle ("superController");
    static IntPtr selSetSuperController_ = Selector.GetHandle ("setSuperController:");
    static IntPtr selTopSubcontroller = Selector.GetHandle ("topSubcontroller");
    static IntPtr selNavigatorURL = Selector.GetHandle ("navigatorURL");
    static IntPtr selOriginalNavigatorURL = Selector.GetHandle ("originalNavigatorURL");
    static IntPtr selFrozenState = Selector.GetHandle ("frozenState");
    static IntPtr selDoNavigatorGarbageCollection = Selector.GetHandle ("doNavigatorGarbageCollection");
    static IntPtr class_ptr = Class.GetHandle ("TTBaseViewController");
    [Export ("init")]
    public  TTBaseViewController () : base (NSObjectFlag.Empty)
    {
        Handle = MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSend (this.Handle, Selector.Init);
    }
    public TTBaseViewController (NSObjectFlag t) : base (t) {}
    public TTBaseViewController (IntPtr handle) : base (handle) {}

当自定义视图控制器没有';t直接从UIViewController继承

MonoDevelop 2.8.8.3仍然存在此问题吗?

这听起来像是一个已经在测试版中解决的问题。

ok,从绑定项目中创建的类继承并引用绑定项目而不是绑定项目创建的.dll时,似乎会出现问题。如果直接引用dll,则会正常创建.h文件。

通过

让开发/测试有点麻烦