简体   繁体   English

UILabel和UIButton没有显示

[英]UILabel and UIButton not showing

I have a simple display with one UIImageView, two UIButton, and two UILabel. 我有一个简单的显示器,一个UIImageView,两个UIButton和两个UILabel。 UIImageview appears successfully, but the others don't... and I have no idea why since they are all declared and invoked the same way... UIImageview看起来很成功,但是其他人没有......而且我不知道为什么因为它们都以相同的方式被声明和调用...

btw, I'm not using interface builder at all, and everything is done programmatically. 顺便说一句,我根本就没有使用界面构建器,一切都是以编程方式完成的。

following is my interface 以下是我的界面

@interface selectGender : UIViewController {
IBOutlet UIButton *mButton;
IBOutlet UIButton *fButton;
IBOutlet UILabel *mLabel;
IBOutlet UILabel *fLabel;
IBOutlet UIImageView *logo;
}

and following is my implementation 以下是我的实施

-(void) start{
logo = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CosmicRabbit.jpg"]];
logo.frame = CGRectMake(200, 400, 320, 460);


NSLog(@"in start");
mLabel.frame = CGRectMake(80.0, 300.0, 275.0, 275.0);
fLabel.frame = CGRectMake(400.0, 300, 275.0, 275.0);
mButton.frame = CGRectMake(80.0, 500.0, 275.0, 275.0);
fButton.frame = CGRectMake(400.0, 500.0, 275.0, 275.0);
mLabel.textColor=[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
mLabel.text=@"Male";
fLabel.textColor=[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
fLabel.text=@"Female";
[mButton addTarget:self action:@selector(playMale)
    forControlEvents:UIControlEventTouchUpInside];
[fButton addTarget:self action:@selector(playFemale)
    forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:mLabel];
[self.view addSubview:fLabel];
[self.view addSubview:mButton];
[self.view addSubview:fButton];
[self.view addSubview:logo];

}

they're all synthesized in the beginning and released in dealloc.. could anyone please help me out... 他们都是在开始时合成并在dealloc中发布..任何人都可以帮助我...

btw, this view invoked as a modal view. 顺便说一下,这个视图作为模态视图调用。

Well, unlike the logo you're not creating that buttons and labels. 好吧,与徽标不同的是,你没有创建那些按钮和标签。 If you're not using IB, then you have to do that manually. 如果您不使用IB,则必须手动执行此操作。 BTW if you're not using IB then you don't need to declare those items as IBOutlet 顺便说一句,如果你没有使用IB,那么你不需要将这些项目声明为IBOutlet

If 'synthesized' them it only means that complier would create automatic accessor-methods for that ivars, he won't instantiate them. 如果'合成'它们只意味着编译器会为该ivars创建自动访问器方法,他将不会实例化它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM