【问题标题】:Using UIImagePickerController with UINavigationController将 UIImagePickerController 与 UINavigationController 一起使用
【发布时间】:2010-07-09 04:09:27
【问题描述】:

所以我有一个 UINavigationController 从 rootViewController 推送一个 UITableViewController。从 UITableViewController,我希望在单击某个单元格时推送 UIImagePickerController。如何让导航控制器显示图像选择器?

【问题讨论】:

    标签: iphone objective-c uinavigationcontroller uiimagepickercontroller


    【解决方案1】:
      - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
        {
           UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
           imagePicker.delegate = self;
    
           [self presentModalViewController:imagePicker animated:YES];
           // don't release imagePicker here
        }
    

    然后在你的 tableViewController 实现中定义UIPickerControllerDelegate。

    【讨论】:

    • 注意第一个是不行的,因为UIImagePickerController本身就是一个UINavigationController,不能嵌入到另一个导航控制器中。此外,这些都不适用于 iPad。根据documentation,您只能在 UIPopoverController 中显示 UIImagePickerController 或作为当前视图的替换。
    • 我认为第一个应该被删除,因为它会导致像shezi states这样的异常,这可能会让阅读这个答案的用户感到困惑。
    猜你喜欢
    • 2013-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-18
    • 2017-05-24
    • 1970-01-01
    • 2013-12-04
    • 1970-01-01
    相关资源
    最近更新 更多