Myt*_*ral 5 iphone objective-c quicklook ipad ios4
我有QuickLook(QLPreviewController)几乎按照我想要的方式工作,但由于图像特征,我不希望它旋转成纵向.我在"shouldAutoRotateToInterfaceOrientation"方法中配置它只返回yes用于横向旋转(参见下面的代码详细信息)但它仍然旋转到肖像.
注意: shouldAutoRotateToInterfaceOrientation是一个直接副本,在我的所有视图控制器中用于此项目,它在其他视图控制器中工作.
//
// documentViewer.m
//
#import "DocumentViewer.h"
@implementation DocumentViewer
@synthesize documents;
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
return YES;
else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight)
return YES;
else
return NO;
}
- (void)viewDidLoad {
[super viewDidLoad];
}
//-(void)viewWillAppear:(BOOL)animated {
//
// self.userInteractionEnabled = YES;
//}
//Nessary for Enabling User Interaction
- (BOOL)canBecomeFirstResponder {
return YES;
}
-(void) createList:(NSString *) document {
documents = [[NSArray arrayWithObjects:document, nil] retain];
}
-(NSInteger) numberOfPreviewItemsInPreviewController: (QLPreviewController *) controller {
return [documents count];
}
- (id <QLPreviewItem>) previewController: (QLPreviewController *) controller previewItemAtIndex: (NSInteger) index {
return [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:[documents objectAtIndex:index] ofType:nil]];
}
@end
Run Code Online (Sandbox Code Playgroud)
小智 5
在AppDelegate.m中替换
返回UIInterfaceOrientationMaskAll;
同
返回UIInterfaceOrientationMaskLandscape;
像这样:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
return UIInterfaceOrientationMaskLandscape;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3334 次 |
| 最近记录: |