gpt4 book ai didi

iphone - 从内部 View Controller 推送 View Controller

转载 作者:行者123 更新时间:2023-11-29 13:41:49 25 4
gpt4 key购买 nike

this question 中所述,我有一个 View Controller 需要在某些可能不存在数据的情况下用不同的布局替换自己。这似乎有效:

if ([analysis length] == 0) {
hasReview = NO;
UnreviewedSPP* unreviewedSPPView = [[UnreviewedSPP alloc] init];
unreviewedSPPView.ProductName = self.productName;
unreviewedSPPView.SdcId = self.sdcId;
unreviewedSPPView.Delegate = self;
NSArray* newViews = [[NSBundle mainBundle] loadNibNamed:@"UnreviewedSPP" owner:unreviewedSPPView options:nil];
self.view = [newViews objectAtIndex:0];
return;
}

但是,我似乎无法从替换 View 中推送新的 View Controller :

    [priceButton handleControlEvent:UIControlEventTouchUpInside withBlock:^{
WebViewController* wv = [[[WebViewController alloc] initWithNibName:@"WebViewController" bundle:nil] autorelease];
wv.url = offerURL;
[Delegate performSelector:@selector(pushViewControllerFromSubview:) withObject:wv];
}];

priceButton 是一个自定义按钮对象,可以执行 block 作为目标操作。

我尝试了多种方法:将外部 View Controller 作为委托(delegate)传递,并将外部 View Controller 的导航 Controller 作为内部 View Controller 的属性传递。

似乎没有任何效果。有更好的解决方案吗?

最佳答案

问题:

1) 当你调用 pushViewControllerFromSubview 时 wv 是否被保留?我注意到你在这里有自动释放协议(protocol)。检查 pushViewControllerFromSubview 中的 wv View 。

2) 替换 View 的另一种方法是使用'[self.view addSubView:myView];'和 [myView removeFromSuperView];'...这可能是比推送 View Controller 更好的方法。

干杯

关于iphone - 从内部 View Controller 推送 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8883376/

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