프로그래밍 방식으로 툴바에 버튼을 추가했지만 작동하지 않습니다. 내 코드에 무슨 문제가 있습니까? 그것도 압박 할 수 없다. 그것의 도구 모음에 그냥 그림처럼.눌렀을 때 툴바 버튼이 활성화되지 않습니다
-(void)viewWillAppear:(BOOL)animated{
//Toolbar send button
UIView *buttonContainer1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 44)];
buttonContainer1.backgroundColor = [UIColor clearColor];
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
[button1 setBackgroundImage:[UIImage imageNamed:@"send.png"] forState:UIControlStateNormal];
const CGSize button1Size = [button1 sizeThatFits:CGSizeZero];
[button1 setFrame:CGRectMake([UIScreen mainScreen].bounds.size.width-40, 27, button1Size.width, button1Size.height)];
[button1 addTarget:self action:@selector(button1Action:) forControlEvents:UIControlEventTouchUpInside];
[button1 setShowsTouchWhenHighlighted:YES];
[buttonContainer1 addSubview:button1];
}
-(IBAction)button1Action:(id)sender{
textField.textColor = [UIColor lightGrayColor];
textField.text = @"the message was sent";
[textField resignFirstResponder];
}
나는 당신이 말하는 것을 보았습니다. 내 크기를 어떻게 설정해야합니까? – ian
버튼의 너비와 높이를 찾을 수 있습니까? –
자산 카탈로그의 크기를 조정할 수있는 이미지이기 때문에 사용되는 기기에 따라 바뀝니다. – ian