【发布时间】:2010-11-23 20:27:08
【问题描述】:
-(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)refersh:(id)sender{
}
上面的代码显示了一个带有按钮的文本字段,但是当我点击它时,模拟器崩溃了。我不明白它背后的区域是什么。任何人都告诉我哪里错了
【问题讨论】:
标签: iphone objective-c uibutton uitextfield