如何解决插座在Interface BuilderXcode 3或Xcode4中都没有显示
|| 我正在学习开发iOS应用程序(我是Objective-C和Cocoa的新手),并且我在做这个非常简单的示例练习(两个标签显示在Label中按下了Left或Right按钮)。 我只创建了一个IBOutlet和几行代码,保存了两个AppViewController文件,当尝试将IBOutlet与Interface Builder中的实际标签连接时,插座没有显示。 我正在使用iOS SDK 4.3 这是源代码://
// BotonViewController.h
// Boton
//
// Created by Abu on 5/23/11.
// copyright 2011 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface Hola_MundoViewController : UIViewController {
IBOutlet UILabel *statusText;
}
@property (retain,nonatomic) UILabel *statusText;
-(IBAction)buttonpressed: (id)sender;
@end
和
//
// BotonViewController.m
// Boton
//
// Created by Abu on 5/23/11.
// copyright 2011 __MyCompanyName__. All rights reserved.
//
#import \"BotonViewController.h\"
@implementation Hola_MundoViewController
@synthesize statusText;
-(IBAction)buttonpressed: (id)sender
{
Nsstring *title = [sender titleForState:UIControlStatenormal];
Nsstring *newText = [[Nsstring alloc] initWithFormat:
@\"%@ button pressed.\",title];
statusText.text = newText;
[newText release];
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotatetoInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (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 {
[statusText release];
[super dealloc];
}
@end
好吧,就是这样,希望您能为我提供帮助,这可能是一个愚蠢的错误,但是我已经浏览了很多,但找不到解决方案。
解决方法
您的财产声明应如下所示
@property (retain,nonatomic) IBOutlet UILabel *statusText;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。