Outlet 未显示在 Interface Builder (Xcode 3) 或 Xcode4 中
我正在学习开发 iOS 应用程序(我是 Objective-C 和 Cocoa 的新手),并且我正在做这个非常简单的示例练习(两个按钮显示在标签中按下了向左或向右按钮)。
我只是创建一个 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
,就是这样,希望你能帮助我解决这个问题,可能是一个愚蠢的错误,但我浏览了很多,但找不到解决方案。
I'm learning to develop iOS apps (I am a total newbie in Objective-C and Cocoa), and I am doing this really simple example exercise (two buttons that shows Left or Right button is pressed in a Label).
I just create an IBOutlet and a couple of code lines, save both AppViewController files and when trying to connect the IBOutlet with the actual label in the Interface Builder, the outlet doesn't show up.
I'm using the iOS SDK 4.3
Here's the source code:
//
// 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
And
//
// 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
Well, that's it, hope you can help me with this, probably is a silly mistake, but I've browsed a lot and I cannot find a solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的财产申报应该是这样的
Your property declaration should look like this