我无法访问UIImagePickerController
中定义的AppDelegate
。我已在UIImagePickerController
文件中定义AppDelegate.h
对象也使用了其委托。这是我的代码。
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.wantsFullScreenLayout = YES;
picker.allowsEditing=NO;
return YES;
}
我正在viewcontroller文件中使用操作表,并希望以 -
执行此操作viewController.m
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (actionSheet.tag)
{
case 1:
switch (buttonIndex)
{
case 0:
{
AppDelegate *appDelegate = (AppDelegate*) [[UIApplication sharedApplication] delegate];
[appDelegate.window.rootViewController presentModalViewController:appDelegate.picker animated:YES];
}
}
}
}
但是没有显示图像选择器控制器视图。
答案 0 :(得分:0)
我相信Objective c现在会自动合成你的属性,并期待ivar的_picker。用于表示访问您的选择器,如self.picker或self.delegate.picker
答案 1 :(得分:0)
中的
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
不写
[appDelegate.window.rootViewController presentModalViewController:appDelegate.picker animated:YES];
而是尝试写
[appDelegate.window presentModalViewController:appDelegate.picker animated:YES];
让我知道它的工作与否。!!! 快乐编码!!!!!