我有一个标签栏,第一个标签有HomeViewController
,第二个标签有导航控制器有两个ViewControllers - CheckOutViewController
和PaymentViewController
。
我正在尝试在PaymentViewController
上添加一个代理,允许我更新HomeViewController
。
但是,HomeViewController
上的委托方法未被调用。
PaymentViewController
@protocol PaymentViewControllerDelegate <NSObject>
@required
-(void)paymentSuccessfull :(BOOL)isSuccessfull;
@end
@interface PaymentViewController
@property (nonatomic, weak) id <PaymentViewControllerDelegate> paymentDelegate;
-(void)orderProcessed
{
[paymentDelegate paymentSuccessfull : YES];
[self.navigationController popToRootViewControllerAnimated :YES];
}
HomeViewController.m
@interface HomeViewController : UIViewController<PaymentViewControllerDelegate>
// I do not know how to assign delegate here in the tabbar
-(void)paymentSuccessfull:(BOOL)isSuccessfull
{
NSLog(@"success");
}
答案 0 :(得分:0)
据我所知,你有这样的结构:
Tabbar Controller:
- HomeViewController
NavigationController
PaymentViewController
CheckOutViewController
既然您已经将协议添加到 PaymentViewController ,根据您的结构,应该在您实例化PaymentViewController的Controller上调用委托方法(I猜你的情况可能是NavigationController / Tabbar Controller)。 因此,在其中一个控制器中,您将从Storyboard中实例化PaymentViewController,您还必须指定该类符合该委托。
这将是:
double fmin(double, double)
我认为这可以帮助你或指导你。