iphone – 为模态视图控制器数据传输实现委托方法

iphone – 为模态视图控制器数据传输实现委托方法,第1张

概述我有一个简单的项目来呈现一个模态视图控制器,并根据按下的模式VC中的哪个按钮传回一个字符串.我基于在iTunes U上观看Stanford课程.我看起来一切都正确,但我得到了一些编译器警告. 首先,我从TransferViewController.m中的不兼容指针类型中得到一个名为’setDelegate:’的传递参数1 其次,我得到四个警告称为无效接收器类型’id< MyModalViewCon 我有一个简单的项目来呈现一个模态视图控制器,并根据按下的模式VC中的哪个按钮传回一个字符串.我基于在iTunes U上观看Stanford课程.我看起来一切都正确,但我得到了一些编译器警告.

首先,我从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 – 为模态视图控制器数据传输实现委托方法所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1009830.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存