当前位置: 动力学知识库 > 问答 > 编程问答 >

objective c - iphone: Unable to connect the outlet?

问题描述:

I am trying to connect UITextField to file's owner.

Though i have taken

 IBOutlet UITextField *txt1

But i am not able to connect the outlet

Can you please suggest what could be wrong?

网友答案:

My suggestion is checking the type of the file's owner.

It should be exactly the same type as the class where you declared IBOutlet UITextField *txt1.

Also, ensure that IB knows about the outlet (i.e., it lists it in the outlet pane for your file's owner).

网友答案:

From the popup you have open, click and drag from the circle next to New Referencing Outlet to the File's Owner. If you can't see an option for txt1, click on the rightmost of the three buttons above the label View in the top bar. The right pane will appear In the right pane, click the third icon from the left (on the top), and make sure the Class under the Custom Class heading is set to the same class as the file's owner.

网友答案:

Sometimes there is a problem with the class file name. In my case I made a refactory (rename) and forgot to change the custom class attribute for the file's owner, as show in the screen shoot:

网友答案:

I think you have not declared @property in .h file and synthesize it..

u may require to declare property in .h file like this:

@property (nonatomic, retain) UITextField *txt1;

and synthesize in .m file like this..

@synthesize txt1;

make sure "@synthesize txt1" comes after @implementation..

I hope that will help according to my knowledge.. :)

分享给朋友:
您可能感兴趣的文章:
随机阅读: