0
嗨,我試圖在窗口中顯示uiview類對象,但事情是,它沒有顯示不知道什麼原因,我無法解決請幫助我,這裏是我的代碼在窗口中顯示uiview對象
@interface Myview : UIViewController {
UIView *move_view;
UIButton *btn;
}
@end
#import "Myview.h"
@implementation Myview
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)init {
if (self = [super init]) {
// Custom initialization
[move_view setFrame:CGRectMake(41, 91, 64, 82)];
[move_view setBackgroundColor:[UIColor redColor]];
btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btn setFrame:CGRectMake(113, 298, 72, 37)];
[btn setTitle:@"Move" forState:UIControlStateNormal];
[btn addTarget:self action:@selector(moveaview) forControlEvents:UIControlEventTouchUpInside];
}
return self;
}
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
[super loadView];
[self.view addSubview:move_view];
[self.view addSubview:btn];
}
謝謝
謝謝男人這個工作負載嚴重殺死我 謝謝你的幫助,我只是不能相信我跳過那部分感謝很多rano – Radix 2010-08-29 08:44:08
@Radix,很高興它幫助。嘗試將Interface Builder用於這樣的小任務,它將正確地管理IBOutlets alloc和init – rano 2010-08-29 08:48:45