我无法访问在文件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 文件中使用操作表并希望执行此操作 -
视图控制器.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];
}
}
}
}
但图像选择器控制器视图未显示。