任何人都可以告诉我如何改变d出窗口的大小?
- (voID)showImagePickerForPhotolibrary { NSLog(@"Picker"); imagePickerController = [[UIImagePickerController alloc] init]; imagePickerController.delegate = self; imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotolibrary; imagePickerController.contentSizeforVIEwInPopover = CGSizeMake(768,1000); if (UI_USER_INTERFACE_IdioM() == UIUserInterfaceIdiomPad) { Class cls = NSClassFromString(@"UIPopoverController"); if (cls != nil) { popoverController = [[UIPopoverController alloc] initWithContentVIEwController:imagePickerController]; //popoverController.popoverContentSize = CGSizeMake(768,1000); [popoverController presentPopoverFromrect:selectedRect inVIEw:self.vIEw permittedArrowDirections:4 animated:YES]; } } else { [app.mainVIEwController presentModalVIEwController:imagePickerController animated:YES]; } }解决方法 我不确定这是最优雅的解决方案,但它似乎对我来说很好:
您可以将UIImagePickerController的视图嵌入到“容器”UIVIEwController的视图中.
- (voID)showImagePickerForPhotolibrary {NSLog(@"Picker"); imagePickerController = [[UIImagePickerController alloc] init]; imagePickerController.delegate = self; imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotolibrary; UIVIEwController *containerController = [[UIVIEwController alloc] init]; containerController.contentSizeforVIEwInPopover = CGSizeMake(768,1000); [containerController.vIEw addSubvIEw:imagePickerController.vIEw]; if (UI_USER_INTERFACE_IdioM() == UIUserInterfaceIdiomPad) { Class cls = NSClassFromString(@"UIPopoverController"); if (cls != nil) { popoverController = [[UIPopoverController alloc] initWithContentVIEwController:containerController]; [popoverController presentPopoverFromrect:selectedRect inVIEw:self.vIEw permittedArrowDirections:4 animated:YES]; [imagePickerController.vIEw setFrame:containerController.vIEw.frame]; } } else { [app.mainVIEwController presentModalVIEwController:containerController animated:YES]; } }
希望这可以帮助
编辑:由于一些奇怪的原因,框架确实在景观正确时改变.
为了解决这个问题,您需要在显示d出窗口后设置图像选择器的视图框架.
我已经编辑了上面的代码来展示这个.
此外,在您的控制器中,添加以下内容:
- (voID)dIDRotateFromInterfaceOrIEntation:(UIInterfaceOrIEntation)fromInterfaceOrIEntation { [imagePickerController.vIEw setFrame:imagePickerController.vIEw.supervIEw.frame];}总结
以上是内存溢出为你收集整理的objective-c – 通过UIPopOver(iPad)更改UIImagePicker的大小全部内容,希望文章能够帮你解决objective-c – 通过UIPopOver(iPad)更改UIImagePicker的大小所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)