StackScrollView问题与委托ID MBProgressHUD

时间:2012-03-10 19:42:50

标签: iphone ios uiviewcontroller delegates uinavigationcontroller

我使用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。但我无法找到“自我”应该是什么。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

TextView需要实现MBProgressHUD委托协议。在TextView.h中,使它看起来像这样:

@interface TestView : ClassYouInheritFrom <MBProgressHUDDelegate>