您的位置:首页 > 移动开发 > Objective-C

这个可以,在objectC打开相册时,如果是横屏就横屏打开,如果是竖屏就竖屏打开

2015-02-13 00:00 197 查看
摘要: 可以在supportedInterfaceOrientations 控制方向

//添加图片

//-(IBAction)addPic:(id)sender

-(void)addPic:(UIButton *)sender

{

imagePicker = [[UIImagePickerController alloc] init];

imagePicker.delegate = self;

imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

imagePicker.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

imagePicker.allowsEditing = YES;

[self presentViewController:imagePicker animated:YES completion:^{}];

}

//-------------------------------------------------------

@interface UIImagePickerController (LandScapeImagePicker)

- (BOOL)shouldAutorotate;

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation ;

-(NSUInteger)supportedInterfaceOrientations ;

@end

@implementation UIImagePickerController (LandScapeImagePicker)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight );

}

-(NSUInteger)supportedInterfaceOrientations {

if ([[UIDevice currentDevice] orientation]==UIInterfaceOrientationPortrait) {

return UIInterfaceOrientationMaskAllButUpsideDown;

}else if([[UIDevice currentDevice] orientation]==UIInterfaceOrientationLandscapeLeft || [[UIDevice currentDevice] orientation]==UIInterfaceOrientationLandscapeRight){

return UIInterfaceOrientationMaskLandscape;

}else{

return UIInterfaceOrientationMaskAllButUpsideDown;

}

}

- (BOOL)shouldAutorotate {

return NO;

}

@end

//------------------------------------------

另外,如果是ipad不是iphone 相册的选择取消可能是英文

1. UIImagePickerController页面的Cancel和Choose按钮以及截取中得重拍按钮,想改成中文

本来打算通过获取这些按钮的指针进行设置的,最后发现可以在工程中直接 project-->info-->Localization--->language中add一个简体中文就可以了
参考:http://www.cocoachina.com/bbs/read.php?tid=132828
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐