저는 iOS
및 xcode에 새로 입문되었습니다. nib 파일이나 스토리 보드를 사용하지 않고 텍스트 필드를 만들고 싶습니다. 나는 답을 찾았지만 어디서나 혼란스러워하거나 펜촉 파일을 사용했다. 나는 문제를 직면하고있는 텍스트 필드 m을 위해 버튼과 그 일 벌금을 만들었다. 여기 내 viewcontroller.m
도와주세요.ios 용 텍스트 필드
#import "ViewController.h"
@interface ViewController()
@end
@implementation ViewController
- (void)loadView {
self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
self.view.backgroundColor = [UIColor purpleColor];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
UITextField *textfield;
button.frame = CGRectMake(10 ,350 , 300, 40);
button1.frame = CGRectMake(10 ,50 , 300, 40);
textfield.frame = CGRectMake(10, 100, 200, 30);
[button setTitle:@"Change screen to green!" forState:UIControlStateNormal];
[button1 setTitle:@"click screen to red!" forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside];
[button1 addTarget:self action:@selector(buttonPressed1) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
[self.view addSubview:button1];
[self.view addSubview:textfield];
}
-(void)buttonPressed {
self.view.backgroundColor = [UIColor greenColor];
}
-(void)buttonPressed1 {
self.view.backgroundColor = [UIColor redColor];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
@end
감사 & 관련
덕분에 .. 지금 일하고있어. :) – Newbee