- Posted
- Filed under 01010101
그 중에서 버튼을 누르면 UITextField 처럼 하단에서 커스텀 키보드가 나오도록 하는 방법입니다.
UIButton 을 상속받아서 UIResponder 의 - (BOOL)canBecomeFirstResponder 를 구현합니다.
CustomButton.h
[CODE]//
// CustomButton.h
//
// Created by Cho, Young-Un on 11. 9. 2..
// Copyright 2011 cultstory.com. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CustomButton : UIButton {
@private
UIView *_inputView;
}
@property (nonatomic, retain) UIView *inputView;
@end[/CODE]
CustomButton.m
[CODE]//
// CustomButton.m
//
// Created by Cho, Young-Un on 11. 9. 2..
// Copyright 2011 cultstory.com. All rights reserved.
//
#import "CustomButton.h"
@implementation CustomButton
@synthesize inputView=_inputView;
- (void)dealloc {
[_inputView release];
[super dealloc];
}
- (BOOL)canBecomeFirstResponder {
return YES;
}
@end[/CODE]
사용법
[CODE]UIPickerView *pickerView = [[[UIPickerView alloc] initWithFrame:CGRectMake(0, 10, 320, 216)] autorelease];
pickerView.delegate = self;
pickerView.dataSource = self;
pickerView.showsSelectionIndicator = YES;
CustomButton customButton = [[CustomButton alloc] initWithFrame:CGRectMake(10, 10, 300, 40)];
customButton.inputView = pickerView;
[button becomeFirstResponder];[/CODE]