【发布时间】:2014-02-20 15:27:03
【问题描述】:
我在导航栏中有一个按钮和一个搜索字段,我通过一个类的代码为所有视图添加了一个新按钮。
问题是:在按钮视图中,另一个按钮和添加故事板的搜索字段不是更可触摸且不起作用。
UIImage * buttonImage = [UIImage imageNamed:@"chat-notify.png"];
button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addTarget:self
action:@selector(goChat)
forControlEvents:UIControlEventTouchDown];
//[button setTitle:@"1" forState:UIControlStateNormal];
button.frame = CGRectMake(280.0, 25.0, 30.0, 30.0);
[button setBackgroundImage:buttonImage forState:UIControlStateNormal];
[self.view addSubview:button];
然后在控制器中:
notificationViewController* notification = [[notificationViewController alloc]init];
//[notification methodA];
[notification makeButtonNotification];
[self.view addSubview:notification.view];
有谁知道我的错误在哪里?
谢谢
【问题讨论】:
标签: ios objective-c uibutton programmatically-created