2011-01-20 11 views

答えて

12
-(void)ViewDidLoad{ 
    UITextField *txt = [[UITextField alloc]initWithFrame:CGRectMake(140, 120, 160, 40)]; 
    txt.returnKeyType = UIReturnKeyDone; 
    txt.placeholder = @"enter name"; 
    [txt setBorderStyle:UITextBorderStyleRoundedRect]; 
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 
    [button setImage:[UIImage imageNamed:@"icon_chapter.png"] forState:UIControlStateNormal]; 
    button.imageEdgeInsets = UIEdgeInsetsMake(0, -16, 0, 0); 
    [button addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventTouchUpInside]; 
    txt.rightView = button; 
    txt.rightViewMode = UITextFieldViewModeAlways; 
    [self.view addSubview:txt]; 
} 

-(IBAction)refresh:(id)sender{ 

} 
+0

thanx作品 – sugita

0

あなたはUITextFieldの中にボタンを追加したいのですか?

私の推測が正しい場合は、ボタンを 'UITextField'に追加することができます。

'in' UITextFieldを入れる必要はありません。

関連する問題