首先,我从TransferVIEwController.m中的不兼容指针类型中得到一个名为’setDelegate:’的传递参数1
其次,我得到四个警告称为无效接收器类型’ID< MyModalVIEwControllerDelegate> *’但这些警告不显示在构建结果区域中,而是显示在MyModalVIEwController.m中的违规行旁边,每个按钮 *** 作中都有两行.
这是代码……
// TransferVIEwController.h#import <UIKit/UIKit.h>#import "MyModalVIEwController.h";@interface TransferVIEwController : UIVIEwController <MyModalVIEwControllerDelegate> { UILabel *label; UIbutton *button;}@property (nonatomic,retain) IBOutlet UILabel *label;@property (nonatomic,retain) UIbutton *button;- (IBAction)updateText;@end
// TransferVIEwController.m#import "TransferVIEwController.h"@implementation TransferVIEwController@synthesize label;@synthesize button;- (IBAction)updateText { MyModalVIEwController *myModalVIEwController = [[MyModalVIEwController alloc] init]; myModalVIEwController.delegate = self; // I get the warning here. [self presentModalVIEwController:myModalVIEwController animated:YES]; [myModalVIEwController release];}- (voID)myModalVIEwController:(MyModalVIEwController *)controller dIDFinishSelecting:(Nsstring *)selectedDog { label.text = selectedDog; [self dismissModalVIEwControllerAnimated:YES];}@end
// MyModalVIEwController.h#import <UIKit/UIKit.h>@protocol MyModalVIEwControllerDelegate;@interface MyModalVIEwController : UIVIEwController { UIbutton *abby; UIbutton *zion; ID <MyModalVIEwControllerDelegate> delegate;}@property (assign) ID <MyModalVIEwControllerDelegate> delegate;- (IBAction)selectedAbby;- (IBAction)selectedZion;@end@protocol MyModalVIEwControllerDelegate <NSObject>@optional- (voID)myModalVIEwController:(MyModalVIEwController *)controller dIDFinishSelecting:(Nsstring *)selectedDog;@end
// MyModalVIEwController.m#import "MyModalVIEwController.h"@implementation MyModalVIEwController@synthesize delegate;- (IBAction)selectedAbby { if ([self.delegate respondsToSelector:@selector (myModalVIEwController:dIDFinishSelecting:)]) { [self.delegate myModalVIEwController:self dIDFinishSelecting:@"Abby"]; }}- (IBAction)selectedZion { if ([self.delegate respondsToSelector:@selector (myModalVIEwController:dIDFinishSelecting:)]) { [self.delegate myModalVIEwController:self dIDFinishSelecting:@"Zion"]; }}解决方法 在ID< something>之后摆脱那些* s在代表之前.
所以说吧
ID <MyModalVIEwControllerDelegate> *delegate;
这个
ID <MyModalVIEwControllerDelegate> delegate;总结
以上是内存溢出为你收集整理的iphone – 为模态视图控制器数据传输实现委托方法全部内容,希望文章能够帮你解决iphone – 为模态视图控制器数据传输实现委托方法所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)