【问题标题】:StackScrollView issue with delegate ID MBProgressHUD委托 ID MBProgressHUD 的 StackScrollView 问题
【发布时间】:2012-03-10 19:42:49
【问题描述】:

我有一个使用 PSStackedView 的堆栈滚动视图应用程序(如 Twitter 和 Facebook 应用程序)

它使用这个堆栈创建视图:

AppDelegate

// set root controller as stack controller
MenuRootController *menuController = [[MenuRootController alloc] init];
self.stackController = [[PSStackedViewController alloc] initWithRootViewController:menuController];
self.window.rootViewController = self.stackController;
[self.window makeKeyAndVisible];

根导航控制器有一个 UItable,一个单元格触摸加载下一个视图

// Load Home Stories table

PSStackedViewController *stackController = XAppDelegate.stackController;
UIViewController*viewController = nil;

while ([stackController.viewControllers count]) {
    //NSLog(@"launchStories");
    [stackController popViewControllerAnimated:YES];
}

viewController = [[TestView alloc] initWithNibName:@"TestView" bundle:nil];     

((TestView *)viewController).indexNumber = [stackController.viewControllers count];
viewController.view.width = roundf((self.view.width - stackController.leftInset)/2);

if (viewController) {
    [XAppDelegate.stackController pushViewController:viewController fromViewController:nil animated:YES];
}

在这个视图中,我想使用 MBProgressHUD (https://github.com/matej/MBProgressHUD/) 来显示一个很好的加载 XML 消息

    HUD = [[MBProgressHUD alloc] initWithView:self.view.window];
    [self.view.window addSubview:HUD];

    HUD.delegate =  self ;
    HUD.labelText = @"Loading";

    [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];

但是

HUD.delegate =  self ;

引发警告并且应用程序崩溃

Assigning to 'id<MBProgressHUDDelegate>' from incompatible type 'TestView *'

我尝试了各种组合来尝试找到当前控制器,但无济于事,我可以找到当前控制器的宽度,例如

PSStackedViewController *stackController = XAppDelegate.stackController;
NSLog(@"%f",stackController.view.width);

打印 748.000000。但我无法弄清楚“自我”应该是什么。

有什么想法吗?

【问题讨论】:

    标签: iphone ios uiviewcontroller delegates uinavigationcontroller


    【解决方案1】:

    TestView 需要实现 MBProgressHUDDelegate 协议。在 TestView.h 中让它看起来像这样:

    @interface TestView : ClassYouInheritFrom <MBProgressHUDDelegate>
    

    【讨论】:

    • 噢!谢谢你。我讨厌它是如此明显
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多