我有一个基于导航的应用程序,它有一个详细视图(UIWebView),在UIToolbar的底部有操作按钮.我想在按下"音符"按钮时添加"音符".当webview处于纵向模式时,一切正常.我按下音符按钮,模态视图打开很好,效果很好.
当webview处于横向模式时,会出现此问题.如果我按下音符按钮,所有打开模态视图的代码都会被调用,但我得到的只是一个白色屏幕.一条评论:如果我以纵向打开模态视图然后旋转设备,它会精细旋转到横向模式.它只是无法在横向模式下正确打开.
我有另一个按钮,它会调出具有相同行为的邮件编辑器.这是我的UIWebViewController中的代码:
- (IBAction)addNotes:(id)sender
{
NotesViewController *notesViewController;
// create the view controller and set it as the root view of a new navigation
// controller
notesViewController = [[NotesViewController alloc] initWithPrimaryKey:self.record.primaryKey];
UINavigationController *newNavigationController =
[[UINavigationController alloc] initWithRootViewController:notesViewController];
// present the navigation controller modally
[self presentModalViewController:newNavigationController animated:YES];
[notesViewController release];
[self.view setNeedsDisplay]; // not sure if I need this! I was trying different things...
[self.devotionText setNeedsDisplay]; // ditto...
[newNavigationController release];
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?我尝试过各种不同的东西都无济于事.我只是得到一个没有导航栏的白色屏幕(尽管顶部有一个状态栏).
我目前在模态视图和弹出窗口方面遇到了一些麻烦.这可能是同样的问题,但我不确定.
我对模态视图的问题是我无法更改动画或过渡样式.例如,我写
self.modalPresentationStyle = UIModalPresentationPageSheet;
self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:IpModal animated:YES];
Run Code Online (Sandbox Code Playgroud)
但是模态视图仍然以其原始过渡样式显示为全屏.
此外,我与弹出窗口的问题是非常相似的.即使我使用"NO"作为参数调用dismissPopover:animated:方法,转换仍然是动画的.
提前致谢.
我在主ViewController中覆盖-orientationChanged,以便在设备处于横向模式时推送ModalViewController A. 当以纵向模式放回时,ModalViewController A被解除.但是,还有其他情况(按钮触摸后),其中显示了ModalViewControllers B,C或D. 当这些显示时,如果设备被转向横向并向后转,ModalViewController BC或D被不适当地解雇.
即使显示了ModalViewController,我也可以验证我的主ViewController上的-orientationChanged是否正在被消息.在显示ModalViewController BC或D时,是否存在我可以添加到-orientationChanged方法以绕过该代码的条件?
谢谢!
如何更改表单工作模式视图控制器的位置?
默认情况下,它位于屏幕的中心,我想偏移表单位置,以便当我显示键盘时,它不会与表单工作窗口重叠.
这可能吗?
我疯狂地想要在我的项目中呈现和解散AVCaptureSession(在视图控制器中).我目前在iOS5.1上并启用了ARC.
我第一次出现viewcontroller并开始会话时可以正常工作但是当我解雇并再次出现时会话将无法启动.我订阅了"AVCaptureSessionRuntimeErrorNotification"通知并收到以下错误:
"错误域= AVFoundationErrorDomain代码= -11819"无法完成操作"UserInfo = 0x1a4020 {NSLocalizedRecoverySuggestion =稍后再试.,NSLocalizedDescription =无法完成操作}"
我假设在我的会话中没有正确发布某些内容,但是ARC没有发布,而是我将所有内容都设置为nil.
我的viewDidLoad方法基本上只是触发initCamera
initCamera方法:
AVCaptureSession *tmpSession = [[AVCaptureSession alloc] init];
session = tmpSession;
session.sessionPreset = AVCaptureSessionPresetMedium;
captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
captureVideoPreviewLayer.frame = self.vImagePreview.bounds;
[self.vImagePreview.layer addSublayer:captureVideoPreviewLayer];
rearCamera = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = nil;
input = [AVCaptureDeviceInput deviceInputWithDevice:rearCamera error:&error];
if (!input) {
// Handle the error appropriately.
NSLog(@"ERROR: trying to open camera: %@", error);
}
[session addInput:input];
videoDataOutput = [[AVCaptureVideoDataOutput alloc] init];
NSDictionary *outputSettings = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kCVPixelFormatType_32BGRA], kCVPixelBufferPixelFormatTypeKey, …Run Code Online (Sandbox Code Playgroud) modalviewcontroller ios avcapturesession automatic-ref-counting
这似乎是整个Apples应用程序中使用的模式; 通过模态视图创建新记录,需要保存或取消以继续,并且通过推入导航堆栈的视图来编辑记录.
基本上将我的ViewController复制为"添加"和"编辑"似乎并不正确,但推送和模态ViewControllers的工作方式有很多不同之处.
我应该怎么做才能覆盖两个基地?
-
差异包括.
当推入堆栈时,导航栏出现在视图的顶部,可以配置为包含取消/保存按钮.当以模态方式呈现时,情况并非如此,因此复制界面需要单独创建工具栏并关闭/保存添加到此的按钮.
当解除推送视图时,我们向导航控制器发送消息[self.navigationController popViewControllerAnimated:YES];,当解除模态视图时,我们向自己发送消息[self dismissModalViewControllerAnimated:YES];
如何在显示模态时从模态segue中删除过渡效果,如下所示:
[self performSegueWithIdentifier:@"SomeIdentifier" sender:self];
Run Code Online (Sandbox Code Playgroud)
我知道我可以进入故事板并在4种不同的动画之间切换,但我不想要任何动画!我该如何删除它们?
我知道我可以说,presentModalViewController animated: NO但我没有,也不能这样称呼它.我需要使用该performSegueWithIdentifier方法.
所以我在Xcode中使用"Utility Application"模板并拥有主视图控制器,用户可以使用按钮隐藏和显示状态栏.我还有一个Flipside View控制器,使用模态segue,它有一个完成按钮返回到主VC.我已将其设置为每次查看Flipside VC时,状态栏始终不会被隐藏.这意味着如果用户隐藏主VC上的状态栏并转换到Flipside VC,它将动画显示,如果用户没有隐藏状态栏并且他们转换,则状态栏没有任何反应.
这一切都很好,问题是从转变回到贫乏VC到主VC.我需要一个条件来检查主VC中状态栏的隐藏状态,当按下完成按钮时,它将在Flipside VC中调用.
我已经研究过使用BOOL和NSNotificationCenter向Flipside VC发送有关状态栏状态的消息.
我有这个代码:
-(BOOL)checkStatusBarHidden:(id)input
{
BOOL result;
if ([UIApplication sharedApplication].statusBarHidden = YES)
{
result = YES;
}
else
{
result = NO;
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
但这只是猜测和思考我可以在某处使用它来通知Flipside VC状态栏状态.我想到也许改变了
[UIApplication sharedApplication].statusBarHidden = YES)
Run Code Online (Sandbox Code Playgroud)
喜欢的东西
self.statusBarHidden = YES //which of course isn't going to work
Run Code Online (Sandbox Code Playgroud)
但无论如何,正如我所说,这是在猜测,我不知道该怎么做.
我有一个奇怪的问题,我只是做一个简单的呈现模态视图控制器.MFMailComposeViewController确切地说.但是,它出现在呈现控制器后面,因此您无法发送任何电子邮件或类型.您可以UINavigationBar在邮件编辑器上看到"取消"按钮,但会弹出UIAlertController显示控制器的后面.这是怎么发生的?这是iOS 11问题吗?对于UIAlertControllers 我也有类似的行为.
此外,如果我按下发送并按下我的按钮以弹出另一个Composer,它将正常工作.这只是第一个.
请参阅我从Xcode获得的附图.
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
mailer.modalPresentationStyle = UIModalPresentationFormSheet;
[mailer setSubject:@"subject Feedback"];
[mailer setToRecipients:@[@"email address"]];
[mailer setMessageBody:@"" isHTML:NO];
[self presentViewController:mailer animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
编辑:添加控制器以获取更多信息.
#import "AboutViewController.h"
#import <MessageUI/MessageUI.h>
@interface AboutViewController () <MFMailComposeViewControllerDelegate>
@property (nonatomic, strong) IBOutlet UIView *contentView;
@end
@implementation AboutViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"About this app";
_contentView.layer.cornerRadius = 10.;
_contentView.layer.shadowColor = [UIColor blackColor].CGColor;
_contentView.layer.shadowRadius = 3.;
_contentView.layer.shadowOpacity = 0.4;
_contentView.layer.shadowOffset …Run Code Online (Sandbox Code Playgroud) 我有一个 SwiftUI 视图,其中包含一个指向 UIViewControllerRepresentable 结构的工作表,该结构使用 Google Ad Manager 扩展。我希望 UIKit 扩展在使用演示模式运行完成后关闭该工作表,但通过环境使用演示模式不起作用。代码是否未按照我设置的方式运行,或者是否无法从 Google Ads Manager 中关闭该工作表?
或者,当我尝试使用 Binding 关闭工作表以更新 AdManager 中的 isPresented 时,我收到错误消息:“属性 'self.isPresented' 未在 super.init 调用中初始化”。然而,当我尝试初始化它时,它说我不能在 super.init 之前执行它,而当我将它放在 super.init 之后时,它说我不能在 super.init 之后调用它。广告加载完成后,有什么方法可以关闭该工作表(函数rewardedAdDidDismiss)?
编辑:这篇文章最初被标记为重复,但链接的问题询问如何从 UIViewController 中消除 SwiftUI 模式,而不是相反。
SwiftUI 视图:
import SwiftUI
struct AdRevenue: View {
@State var playAd = false
@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
var body: some View {
Button(action: {
self.playAd = true
})
{
Text("Play Ad")
}.sheet(isPresented: $playAd) {
Ads()}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的 UIViewControllerRepresentable:
import GoogleMobileAds
import SwiftUI …Run Code Online (Sandbox Code Playgroud) ios ×7
objective-c ×4
iphone ×2
xcode ×2
admob ×1
ios11 ×1
mfmailcomposeviewcontroller ×1
statusbar ×1
storyboard ×1
swift ×1
swiftui ×1
uikit ×1