【发布时间】:2014-12-16 01:51:37
【问题描述】:
好的,我有一个带有自定义扩展单元格的 UITableView。单元格有一个 .xib .m 和 .h 。我正在尝试使用一个按钮来打开相机以拍照并将其保存在按下按钮的单元格中。但它不工作。我已经研究了过去几天,找不到任何解决方案。这是我在扩展单元格的 .m 文件中的代码:
-(void)awakeFromNib {
// Initialization code
[scroller setScrollEnabled:YES];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:@"+" forState:UIControlStateNormal];
[button sizeToFit];
[button setBackgroundColor:[UIColor redColor]];
button.center = CGPointMake( 25, 50);
[button addTarget:self action:@selector(buttonPressed:)forControlEvents:UIControlEventTouchUpInside];
[self addSubview:button];
}
- (IBAction)buttonPressed:(UIButton *)button {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[picker setDelegate:self];
picker.allowsImageEditing = NO;
//[self presentModalViewController:picker animated:YES];
//[self presentViewController:picker animated:YES completion:nil];
picker.showsCameraControls = YES;
}
我一直在从 buttonPressed 方法注释掉的行中收到错误,它说 "no visible @interface for 'ExpandingCell' declares the selector 'presentModalExpandingCell:animated:'" 我已经尝试了它们(不是同时)并得到了相同的错误。我是 iOS 编程的新手,不确定这意味着什么,所以我不知道从哪里开始修复它。
我应该在 tableview 所在的 ViewController 中而不是在扩展单元格中尝试这个吗? 任何帮助或指导表示赞赏。先感谢您。
【问题讨论】:
标签: ios objective-c iphone xcode uitableview