
我搜索了互联网上的解决方案,他们所说的就是将委托人连接到文件的所有者,并添加该功能,它应该工作,我做到了,没有任何工作.
我有一个确定按钮,它正在工作,还点击屏幕上的任何可用空间正在工作,只是返回按钮….
我正在使用模拟器,没有在iphone上测试. (xcode 3.2.5 64位与4.2模拟器).
这是应该将代理连接到每个textfiled的代码行.
我已经尝试返回YES和NO,没有工作.
我已经尝试了一个特定的对象名称为textFIEld和这种一般的方式,没有工作.
- (BOol)textFIEldShouldReturn:(UITextFIEld *)textFIEld {[textFIEld resignFirstResponder];return NO;} 在:基本视图控制器连接 – >连接 – >我有:代理 – 文件的所有者.在文件所有者的引用网点有:代表 – 圆形文本…..
编辑 – 我以前忘了提到,我已经检查,方法不被称为!
- (BOol)textFIEldShouldReturn:(UITextFIEld *)textFIEld{NSLog(@"Working!!!");[textFIEld resignFirstResponder];return YES; }
我应该怎么做才能实现呢?这就是为什么人们说连接代表,但在我的情况下,它是连接的,而不是触发功能…我知道这是一个愚蠢的问题,但对于像我这样的新手,解决方案不是很明显…
好的,另一个编辑 – 所有我的代码:只是不明白做什么….
这是:basicVIEwController.h:
#import <UIKit/UIKit.h>@interface basicVIEwController : <#superclass#> <UITextFIEldDelegate>@interface basicVIEwController : UIVIEwController <UITextFIEldDelegate> {//every object that we want to interact with (like text fIEld or lable) is call an outlet!!!!//here we define the outlets for our programIBOutlet UITextFIEld *txtname;IBOutlet UILabel *lblMessage; }//here are the getters and setter for our outlets@property (nonatomic,retain) IBOutlet UITextFIEld *txtname;@property (nonatomic,retain) IBOutlet UILabel *lblMessage;//method decleration for the OK button action- (IBAction) doSomething;//method for hIDing the keyboard when clicking on empty area in the app //we will put an invisible button on all area and clicking on it will make keyboard disapear - (IBAction) makeKeyboardGoAway; @end 这是basicVIEwController.m:
#import "basicVIEwController.h" @implementation basicVIEwController //synthesizeing the objects that we made' this will create the getter and setters automaticly @synthesize txtname; @synthesize lblMessage; - (IBAction) doSomething{// makeing keyboard disapear when pressing ok button (doing that form the text fIEld)//when pressing the OK button,the keyboard will disapear and when clicking in the text fIEld it will show again[txtname resignFirstResponder];Nsstring *msg = [[Nsstring alloc] initWithFormat:@"Hello,%@",txtname.text];//the objective-c way for setting the test in the text fIEld[lblMessage setText:msg]; //the regular object orIEnted way//lblMessage.text = msg;[msg release]; } - (IBAction) makeKeyboardGoAway{[txtname resignFirstResponder]; } //when clicking the return button in the keybaord - (BOol)textFIEldShouldReturn:(UITextFIEld *)textFIEld{NSLog(@"Working!!!");[textFIEld resignFirstResponder];return YES; } - (voID)dIDReceiveMemoryWarning {// Releases the vIEw if it doesn't have a supervIEw. [super dIDReceiveMemoryWarning];// Release any cached data,images,etc that aren't in use. } - (voID)vIEwDIDUnload {// Release any retained subvIEws of the main vIEw.// e.g. self.myOutlet = nil; } - (voID)dealloc { [super dealloc]; } @end 也许现在我更清楚了,对不起,我以前没有这样做.
任何人都有一个想法我做错了什么?应该是漂亮的海峡前进…..
编辑 – 添加所有元素的图像,我希望这将有助于我:-)
对于每一个试图帮助的人来说,10倍以上…我真的很喜欢这个框架,它在c和java,python等许多…之后是如此之大,而且我正在和一本书一起工作,但它是为了ios 3.1,也许这是问题…..
解决方法 首先,您应该检查textFIEldShouldReturn:是否通过在方法的开头添加NSLog语句或断点来实际调用.一旦遇到这种情况,请尝试手动声明您的视图控制器符合< UITextFIEldDelegate>您的接口文件中的协议:
@interface YourClass:…< UITextFIEldDelegate>
还声明财产&您的UITextFIEld的插座,在IB中进行适当的连接,并手动将自己声明为UITextFIEld委托:
self.yourUITextFIEldobject.delegate = self;
一旦完成,看看上面的方法是否正在被调用,并确保返回YES.
总结以上是内存溢出为你收集整理的ios – UITextField的代理不工作…返回按钮没有响应全部内容,希望文章能够帮你解决ios – UITextField的代理不工作…返回按钮没有响应所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)