我创建了一个按钮
uploadBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
uploadBtn.frame = CGRectMake(35, 340, 250, 40);
[uploadBtn setTitle:@"Upload" forState:UIControlStateNormal];
[uploadBtn addTarget:self action:@selector(callUpload) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:uploadBtn];
采取行动
-(void)callUpload
{
UploadViewController *uploadObj = [[UploadViewController alloc]init];
[self.navigationController pushViewController:uploadObj animated:YES];
}
但是当我按下按钮时没有事件发生。请帮忙
答案 0 :(得分:0)
Btn的方法应该包括发件人。
更新此行。
[uploadBtn addTarget:self action:@selector(callUpload:) forControlEvents:UIControlEventTouchUpInside];
调用方法,
-(void)callUpload : (id) sender
{
UploadViewController *uploadObj = [[UploadViewController alloc]init];
[self.navigationController pushViewController:uploadObj animated:YES];
}