簡體   English   中英

為什么文本字段代碼對Xcode 8 Obj-C不起作用?

[英]Why doesn't the textfield code work for Xcode 8 Obj-C?

ViewController.h

@interface ViewController : UIViewController{

IBOutlet UITextField *Signup;
IBOutlet UITextField *Login;

}
@property(nonatomic, retain)IBOutlet UITextField *Signup;
@property(nonatomic, retain)IBOutlet UITextField *Login;

-(IBAction)TYPE:(id)sender;

ViewController.m

@synthesize Signup;
@synthesize Login;

-(IBAction)TYPE:(id)sender{
[Signup resignFirstResponder];
[Login resignFirstResponder];
}

在模擬器中,當我單擊文本字段時,出現以下錯誤消息:

2017-04-14 18:43:52.616362 Prototype1 [3075:119579] [MC] systemgroup.com.apple.configurationprofiles路徑的系統組容器為/ Users / robertstoley / Library / Developer / CoreSimulator / Devices / 09556F3B-A7BC-4DF2 -95EB-C3C13B6F39EA / data / Containers / Shared / SystemGroup / systemgroup.com.apple.configurationprofiles 2017-04-14 18:43:52.640402 Prototype1 [3075:119579] [MC]從私有有效用戶設置讀取。 2017-04-14 18:43:52.727 Prototype1 [3075:119579]找不到支持鍵盤iPhone-PortraitChoco-NumberPad的類型4的鍵盤。 使用1316927560_PortraitChoco_iPhone-Simple-Pad_Default 2017-04-14 18:43:53.607676 Prototype1 [3075:119579] [Common] _BSMachError:端口7403; (os / kern)無效功能(0x14)“無法插入COPY_SEND” 2017-04-14 18:43:53.608246 Prototype1 [3075:119579] [Common] _BSMachError:端口7403; (os / kern)無效名稱(0xf)“無法取消分配發送權限”

我已經有兩年沒有使用Xcode了,但是同樣的代碼可以正常工作,為什么它不能用於Xcode 8,iOS 10?

Xcode 8的模擬器非常冗長。 這些消息並不意味着什么特別。

-順便說一句-

您的代碼以老的風格編寫,現在不再是最佳實踐。 更好的是:

@interface ViewController : UIViewController
// It's no longer necessary to have your properties between { and }

@property (nonatomic, weak) IBOutlet UITextField *signup;
@property (nonatomic, weak) IBOutlet UITextField *login;
// IBOutlets should be weak, other properties should be weak or strong for objects, or assign for structs and values.
@end


@implementation ViewController

// You don't have to synthesize your properties anymore.

- (IBAction)type:(id)sender {
    [self.signup resignFirstResponder];
    [_login resignFirstResponder];
    // but you do have to either use self. or underscore to refer to them.
}

@end

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM