gpt4 book ai didi

iphone - StackScrollView 与委托(delegate) ID MBProgressHUD 的问题

转载 作者:行者123 更新时间:2023-11-29 04:45:52 31 4
gpt4 key购买 nike

我有一个使用 PSStackedView 的堆栈 ScrollView 应用程序(如 Twitter 和 Facebook 应用程序)

它使用此堆栈创建 View :

应用程序委托(delegate)

// 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];

根导航 Controller 有一个 UItable,单元格触摸会加载下一个 View

// 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];
}

在此 View 中,我想使用 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 *'

我尝试了各种组合来尝试找到当前 Controller ,但没有成功,我可以使用例如找到当前 Controller 的宽度

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

打印 748.000000。但我找不到“ self ”应该是什么。

有什么想法吗?

最佳答案

TestView需要实现MBProgressHUDDelegate协议(protocol)。在 TestView.h 中使其看起来像这样:

@interface TestView : ClassYouInheritFrom <MBProgressHUDDelegate>

关于iphone - StackScrollView 与委托(delegate) ID MBProgressHUD 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9649599/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com