我希望我的整个项目,在纵向模式下运行,并仅这是观看照片的视图可以打开的风景一样,如果使用Facebook(我们查看照片的他们也转动景观,但其他视图的遗体仍然是肖像)我想知道它是如何完成的,因为我有一张桌子视图,图像是从服务器获取的数据库,每个特定数据都包含不同数量的照片,所以现在我想在此之后,用户选择的照片的,他们应该完全开放,可在横向和纵向以及我没试过限制我的项目人像只留下照片视图在横向/纵向
我与iOS6的
- (BOOL)shouldAutorotate
{
return NO;
}
工作进行查看
在所有视图的实施,使他们能够留在肖像,但他们仍然在横向打开我应该如何加以限制并请任何一个可以告诉我,在我的课之一,我有表视图图像(从数据库加载),我有另一个类打开的最多选择的照片从表
我PhotoView.m类
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary *dic = [photos objectAtIndex:indexPath.row];
NSLog(@" *** url is %@",[dic objectForKey:@"url"]);
[self.delegate showPhotoAtUrl:[dic objectForKey:@"url"]];
}
我PhotoViewController.h类
#import <UIKit/UIKit.h>
@interface PhotoViewController : UIViewController <UIScrollViewDelegate>
{
NSString *url;
UIButton *doneButton;
}
@property (nonatomic, retain) UIImageView *imageView;
- (id) initWithPhotoUrl:(NSString *)photoUrl;
@end
和PhotoViewC ontroller.m类
#import "PhotoViewController.h"
@interface PhotoViewController()
@end
@implementation PhotoViewController
@synthesize imageView;
- (id) initWithPhotoUrl:(NSString *)photoUrl
{
self = [super init];
if(self) {
url = [photoUrl retain];
}
return self;
}
- (void)dealloc
{
[url release];
self.imageView = nil;
[doneButton release];
[super dealloc];
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor blackColor];
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
spinner.tag = 1;
spinner.center = self.view.center;
[spinner startAnimating];
[self.view addSubview:spinner];
[spinner release];
[self performSelectorInBackground:@selector(loadPhotoData) withObject:nil];
doneButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
[doneButton addTarget:self action:@selector(doneTouched) forControlEvents:UIControlEventTouchUpInside];
[doneButton setTitle:@"done" forState:UIControlStateNormal];
[doneButton setBackgroundColor:[UIColor clearColor]];
doneButton.frame = CGRectMake(2, 2, 60, 30);
[self.view addSubview:doneButton];
}
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.title = @"";
self.navigationController.navigationBarHidden = YES;
}
- (void) doneTouched
{
[self.navigationController popViewControllerAnimated:YES];
}
- (void) loadComplete:(NSData *)imageData
{
if(!imageData) return;
UIActivityIndicatorView *spinner = (UIActivityIndicatorView *)[self.view viewWithTag:1];
if(spinner) {
[spinner stopAnimating];
[spinner removeFromSuperview];
}
UIImage *img = [UIImage imageWithData:imageData];
float scale = MIN(self.view.frame.size.width/img.size.width, self.view.frame.size.height/img.size.height);
self.imageView = [[[UIImageView alloc] initWithImage:img] autorelease];
self.imageView.frame = CGRectMake(0, 0, self.imageView.image.size.width*scale, self.imageView.image.size.height*scale);
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
self.imageView.center = scrollView.center;
scrollView.delegate = self;
scrollView.contentSize = self.imageView.frame.size;
scrollView.minimumZoomScale = 1;
scrollView.maximumZoomScale = 2;
[scrollView addSubview:self.imageView];
[self.view addSubview:scrollView];
[scrollView release];
[self.view bringSubviewToFront:doneButton];
}
- (UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return self.imageView;
}
- (void) loadPhotoData
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
[self performSelectorOnMainThread:@selector(loadComplete:) withObject:imageData waitUntilDone:NO];
[pool drain];
}
@end
,并在主类,我有这个方法调用PhotoViewController加载所选照片
- (void) showPhotoAtUrl:(NSString *)url
{
PhotoViewController *vc = [[PhotoViewController alloc] initWithPhotoUrl:url];
[self.navigationController pushViewController:vc animated:YES];
[vc release];
}
现在我的问题是我应该怎么弄得到选择后的图像从表中打开在FB应用程序中打开的相同类型的视图(在纵向/横向兼容视图中打开所选照片)我只能在PhotoViewController类中获得一张照片,任何人都可以告诉我如何我可以将所有照片添加到PhotoViewController类,以便获得我想要的效果吗?...任何代码帮助都将非常有帮助..预先感谢贡献你的时间
总之我有两两件事要做:
我一定要限制我的项目只肖像模式只留下照片的看法有横向/纵向兼容。
我目前在我的表格视图中显示照片,我希望在选择时以与FB或其他应用在查看照片时的相同样式(风景/肖像兼容)中打开。
你可以设置从摘要窗口具体orentation。禁用所有其他支持的方向。它会正常工作。 – Anjan
不,但他也想景观... – IronManGill
是的..这就是为什么我卡住了? – iOSBee