在我的一个仅支持纵向方向的Viewcontroller中.在我的设备上旋转状态栏时,旋转到横向.视图的其余部分仍处于纵向模式.我想阻止状态栏的转动.这个问题只发生在IOS7中
// Overridden function to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
// iPhone: support only upright portrait
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
else
{
// iPad: any orientation is OK
return YES;
}
}
// For iOS6.0 Rotate
- (BOOL)shouldAutorotate
{
return NO;
}
Run Code Online (Sandbox Code Playgroud) 我希望将大图像放入UIwebview中,保持图像比例与图像视图相同.
我该怎么做.?
我的代码如下,以适应Uiwebview中的图像.如果图像很大,那么显示效果不佳.
CGFloat screenWidth = self.view.frame.size.width;
CGFloat screenHeight = self.view.frame.size.height;
NSString *htmlString = [NSString stringWithFormat:@"%@", @"<html><head><meta name='viewport' content='user-scalable=yes,width=device-width'></head><body bgcolor='000000'><img src='%@' width='%f' height='%f' style='max-width:200% max-height:200%'></body></html>"];
imageHTML = [[NSString alloc] initWithFormat:htmlString, fileUrl, screenWidth, screenHeight];
[Webview loadHTMLString:imageHTML baseURL:nil];
[imageHTML release];
Run Code Online (Sandbox Code Playgroud) 当我在iOS8 Beta5 + Xcode6中显示UIAlertController(ActionSheet)时,运行时异常即将到来.
此Bug仅在iPad设备中发生.
我在使用UIAlertController时遇到了轰鸣声异常.
*由于未捕获的异常'NSGenericException'终止应用程序,原因:'UIPopoverPresentationController(<_UIAlertControllerActionSheetRegularPresentationController:0x15794370>)应该在演示发生之前设置非零的sourceView或barButtonItem.
我的代码显示ActionSheet如下
// Cancel Button
UIAlertAction *actionCancel = [UIAlertAction
actionWithTitle:NSLocalizedString(@"IDS_LABEL_CANCEL", nil)
style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
// cancel
//action handler
[self actionHandler:nil withTag:0 withButtonIndex:0];
}];
// print button
UIAlertAction *actionPrint = [UIAlertAction
actionWithTitle:NSLocalizedString(@"IDS_LABEL_PRINT", nil)
style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
//action handler
[self actionHandler:nil withTag:kAttachmentActionSheetTag withButtonIndex:0];
}];
// Create action sheet
UIAlertController *alertController = [UIAlertController
alertControllerWithTitle:nil message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
[alertController addAction:actionCancel];
[alertController addAction:actionPrint];
// show aciton sheet
[self presentViewController:alertController animated:YES
completion:nil] …
Run Code Online (Sandbox Code Playgroud) 我的项目在XCode 6中运行良好.但是,当我在xCode7 Beta中构建项目时,我看到以下错误消息:
OS X xib不支持目标设备类型iPhone
请帮我解决这个错误.