0
我的按鈕不會顯示。有誰知道爲什麼?將UIButton添加爲子視圖,但不顯示。
#import "ViewController.h"
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
CTrial *tt = [CTrial alloc];
[tt hellothere:self];
}
/////////////////////////////
#import "CTrial.h"
@implementation CTrial
- (void) hellothere: (UIViewController*) ss
{
UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btn2 setTag:200];
[btn2 addTarget:self action:@selector(menuSetup:) forControlEvents:UIControlEventTouchUpInside];
[btn2 setFrame:CGRectMake(0,0,300,200)];
[ss.view addSubview:btn2];
}
我已經試過 「身份證」
- (id) hellothere: (UIViewController*) ss
與回報,但仍然沒有
#import <UIKit/UIKit.h>
#import "CButton.h"
@interface CTrial : //UIView
-(void) menuSetup:(UIButton*) btn;
- (id) hellothere: (UIViewController*) ss;
//- (void) hellothere: (UIViewController*) ss;
@end
它仍然只是一個黑色的背景屏幕...如果我刪除CTrial實例它是一個灰色的背景 – jdl 2012-03-03 22:26:08
@jdl抱歉,我沒有注意到它。我編輯了我的答案。 – Saphrosit 2012-03-03 22:31:25
你需要繼承什麼? ... UIView,它可以是什麼...否則你不能「分配」? – jdl 2012-03-03 22:32:56