iphone - Objective-c 同一 View 中的多个委托(delegate) - ECSlidingViewController

标签 iphone ios objective-c ecslidingviewcontroller

我开始测试ECSlidingViewController在我尝试访问 FirstTopViewController 后,我遇到了一个大麻烦 - 因为在 FirstToViewController 中我已经有了 ZBarReaderDelegate已实现,并且委托(delegate)的所有示例都没有触发我的委托(delegate)中的任何方法。

基本上我有这些东西:

FirstTopViewController.h

#import ...MyStuff...
#import "UnderRightViewController.h"

@interface FirstTopViewController : UIViewController <RightViewDelegate, ZBarReaderDelegate>

@property (weak, nonatomic) IBOutlet UITextView *labelTotal; 

@end

FirstTopViewController.m

#import "FirstTopViewController.h"

@implementation FirstTopViewController
- (void)setTotalViewController:(UnderRightViewController*)controller didTotalChange:(NSString*)total
{
    //labelTotal.text = total;
    NSLog(@"I'm here!!! and received %@", total);
}

从另一边我有

UnderRightViewController.h

#import <UIKit/UIKit.h>
#import "ECSlidingViewController.h"

@class UnderRightViewController;

@protocol RightViewDelegate <NSObject>

- (void)setTotalViewController:(UnderRightViewController*)controller didTotalChange:(NSString*)total;

@end

@interface UnderRightViewController : UITableViewController

@property (nonatomic, weak) id <RightViewDelegate> delegate;

@end

UnderRightViewController.m

#import "UnderRightViewController.h"

@interface UnderRightViewController ()

@end

@implementation UnderRightViewController

@synthesize delegate;

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [delegate setTotalViewController:self didTotalChange:@"foo"];
}
@end

我一整天都在尝试解决这个难题,但我从未被 setTotalViewController 解雇。

提前致谢。

最佳答案

friend ,你犯了一个小错误,当你从 FirstTopViewController 导航到 UnderRightViewController 时,你需要在 FirstTopViewController.m 中执行此操作:-

 UnderRightViewController *obj = [[UnderRightViewController
                                                                  alloc] initWithNibName:@"UnderRightViewController" bundle:nil];

obj.delegate  = self; // u forget to assign protocol handler


[self.navigationController pushViewController:obj animated:YES];


[obj release];

关于iphone - Objective-c 同一 View 中的多个委托(delegate) - ECSlidingViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18907160/

相关文章:

ios - 使用自动布局创建具有多个不同自定义单元格的 UITableView 具有几乎相同的 subview

objective-c - NSPredicate 中的减法

objective-c - 如何在 awakeFromNib 中打开 NSAlert? (注意窗口动画)

ios - Xcode ScrollView 不滚动

android - 图片在 iPhone 上不起作用,但在 Android 上可以吗?

iphone - iOS 数据存储指南。在这种情况下我该怎么办?

iphone - 通过 wifi 与硬件设备进行短信通信的最佳方式

ios - "Proper"定义类的方式 - 属性与方法

ios - 完成处理程序和返回值

iphone - 指针类型不兼容