我有一个几乎完美运行的应用程序.以下是我的应用程序的结构:
故事板上共有6个视图控制器.前3个视图控制器是最重要的.初始视图控制器具有"登录"和"注册"按钮."登录"按钮以模态方式呈现登录视图控制器,"注册"按钮以模态方式呈现注册视图控制器.
注册视图控制器有3个用户名,密码和电子邮件字段,然后是"提交"按钮.提交按钮将数据提交给我的Web服务器,如果所有内容都成功提交,则会调用"performSegueWithIdentifier"方法.
这是声明:
[self performSegueWithIdentifier:@"superSegue" sender:self];
Run Code Online (Sandbox Code Playgroud)
我今晚花了2个小时试图让上面的方法调用工作,它最终确实有效.为了让它工作,我不得不在故事板上选择我的注册视图控制器并转到编辑器>嵌入>导航控制器(如果我没记错的话,我必须这样做,因为注册视图控制器是以模态方式呈现的).然后我从我的注册视图控制器的提交按钮拖到我想要推送到的视图控制器并选择了推送,然后键入标识符名称.
无论如何,以上所有工作完全正常,直到我尝试使用我们推送到使用方法调用的View Controller上的后退按钮.如果我点击后退按钮,它会进入90%的黑色屏幕,顶部有一个空白的导航栏,后面有一个按钮,当然后面按钮也没有任何效果.
这是我在控制台中收到的错误:
Unbalanced calls to begin/end appearance transitions for <VerificationViewController: 0x14ed1bb0>
Run Code Online (Sandbox Code Playgroud)
验证视图控制器是注册视图控制器通过performSegueWithIdentifier方法推送的视图控制器.
有谁知道如何解决这个错误?
我在下面列出了我的故事板在xcode中的样子.有一个我已经编码但尚未连接的视图控制器,不管怎样都不应该有所不同,所以你可以忽略Login VC右侧的View Controller.

objective-c uiviewcontroller uinavigationcontroller ios segue
我有一个使用AV基金会的照片应用程序.我使用AVCaptureVideoPreviewLayer设置了一个预览图层,它占据了屏幕的上半部分.因此,当用户试图拍摄他们的照片时,他们只能看到屏幕的上半部分看到的内容.
这很好用,但是当用户实际拍摄照片并尝试将照片设置为图层的内容时,图像会失真.我做了研究并意识到我需要裁剪图像.
我想做的就是裁剪完整捕获的图像,这样剩下的就是用户最初在屏幕上半部分看到的内容.
我已经能够完成这个,但我通过输入手动CGRect值来做到这一点,但它看起来仍然不完美.必须有一种更简单的方法来做到这一点.
在过去的两天里,关于裁剪图像,我已经完成了关于堆栈溢出的每个帖子,但没有任何工作.
必须有一种方法可以以编程方式裁剪捕获的图像,以便最终图像与预览图层中最初看到的完全相同.
这是我的viewDidLoad实现:
- (void)viewDidLoad
{
[super viewDidLoad];
AVCaptureSession *session =[[AVCaptureSession alloc]init];
[session setSessionPreset:AVCaptureSessionPresetPhoto];
AVCaptureDevice *inputDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = [[NSError alloc]init];
AVCaptureDeviceInput *deviceInput = [AVCaptureDeviceInput deviceInputWithDevice:inputDevice error:&error];
if([session canAddInput:deviceInput])
[session addInput:deviceInput];
CALayer *rootLayer = [[self view]layer];
[rootLayer setMasksToBounds:YES];
_previewLayer = [[AVCaptureVideoPreviewLayer alloc]initWithSession:session];
[_previewLayer setFrame:CGRectMake(0, 0, rootLayer.bounds.size.width, rootLayer.bounds.size.height/2)];
[_previewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
[rootLayer insertSublayer:_previewLayer atIndex:0];
_stillImageOutput = [[AVCaptureStillImageOutput alloc] init];
[session addOutput:_stillImageOutput];
[session startRunning];
}
Run Code Online (Sandbox Code Playgroud)
以下是用户按下按钮捕获照片时运行的代码:
-(IBAction)stillImageCapture {
AVCaptureConnection *videoConnection = nil;
for (AVCaptureConnection *connection in …Run Code Online (Sandbox Code Playgroud) 我正在制作一个简单的照片和视频捕捉应用程序.该应用程序成功允许用户在按下按钮时拍摄照片或视频.但是,只要您完成拍摄照片或视频,它就会提供2个选项:"重拍"和"使用照片"或"使用视频",具体取决于您使用的是哪一个.
如果用户点击"重拍",则只需让他们重新拍摄新照片或视频,但当用户点按"使用照片"或"使用视频"时,屏幕会冻结.
如果我退出冻结的应用程序并查看我的相机胶卷,我刚刚使用该应用程序拍摄的照片已成功保存.因此,当您点击"使用照片"按钮时,尽管应用程序屏幕冻结,但它仍然成功保存到相机胶卷.
有人告诉我"它冻结了,因为它需要一些时间来保存照片并且它正在主线程上运行.你可以使用ALAssetLibrary来修复冻结问题."
但是,我不熟悉ALAssetLibrary或者为何在这种情况下有用的理论.我只是浏览了一些文档,但我仍然迷失了.
任何帮助将不胜感激.
这是我到目前为止的代码:
ViewController.h:
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
@property UIImagePickerController * pickerController;
-(IBAction)showCameraUI;
@end
Run Code Online (Sandbox Code Playgroud)
ViewController.m:
#import "ViewController.h"
#import <MobileCoreServices/MobileCoreServices.h>
@interface ViewController () <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
//The above are the 2 delegates required for creating a media capture/camera app.
- (void)imagePickerController:pickerController didFinishPickingMediaWithInfo:(NSDictionary *)info;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
[UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
NSLog(@"%ld", (long)UIImagePickerControllerSourceTypeCamera);
}
- (void)didReceiveMemoryWarning
{ …Run Code Online (Sandbox Code Playgroud) 当我单击其中一个wordpress帖子的分享按钮时,会成功打开一个弹出窗口.它显示正确的缩略图图像,标题和摘要文本也是正确的.
但是,当我真正去看看Facebook上的分享时,缩略图是不正确的.出于某种原因,Facebook总是会显示我为每个共享份额创建的第一个共享的缩略图.
奇怪的是标题和摘要总是正确的,但我无法使缩略图正常工作.
这是我用于Facebook共享按钮的代码:
<a class="facebook" onclick="return !window.open(this.href, 'Facebook', 'width=640,height=300')" href="http://www.facebook.com/sharer.php?s=100&p[title]=This Is The Title Of My Post&p[summary]=This is the summary of my post.&p[url]=http://www.mywebsite.com/individual-wordpress-post/&p[images[0]=http://www.mywebsite.com/images/this-is-my-thumbnail-image.jpg" target="_blank"><img class="size-full wp-image-96 alignleft" alt="shareonfacebook" src="http://www.mywebsite.com/images/this-is-my-facebook-share-button-image.jpg" /></a>
Run Code Online (Sandbox Code Playgroud)
在这里阅读以下答案后,我将这些代码放在一起.
任何想法为什么标题和摘要总是正确的,但缩略图永远不对?请记住,当我单击分享按钮时,缩略图在弹出窗口中是正确的,但是当我去看Facebook上的分享时,缩略图是不一样的.
感谢您的帮助,我真的很感激.
我有一个子视图,我已经通过使用frame属性并将其值设置为CGRectMake函数的参数值来自定义它的大小.
我已经慢慢但肯定地改变了CGRectMake参数并重新运行应用程序以使子视图在屏幕上的正确位置,但我知道必须有一种更简单的方法.
这是我目前正在做的事情:
UIImageView *halfView = [[UIImageView alloc]initWithImage:image];
[self.view addSubview:halfView];
halfView.frame = CGRectMake(0, 0, 320, 270);
Run Code Online (Sandbox Code Playgroud)
有没有办法让我不必手动将这4个参数输入到CGRectMake中,只需将其设置为屏幕的前50%?
这就是我希望子视图在iphone屏幕上的样子:

感谢您的帮助.
我正在开发一个简单的照片和视频捕获应用程序。该应用程序成功允许用户按下按钮即可拍摄照片或视频。但是,一旦完成拍摄照片或视频,它会提供2个选项:“重新拍摄”和“使用照片”或“使用视频”,具体取决于您使用的是哪个。
如果用户点击“重新拍摄”,则只是让他们重新拍摄新照片或视频,但是当用户点击“使用照片”或“使用视频”时,它什么也不做。该应用程序仅将它们带回主应用程序屏幕。
我对如何访问“使用照片” /“使用视频”按钮感到困惑,以便我可以编辑它的代码并将其保存到相机胶卷中。
这是我到目前为止的代码:
ViewController.h:
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
@property UIImagePickerController * pickerController;
-(IBAction)showCameraUI;
@end
Run Code Online (Sandbox Code Playgroud)
ViewController.m:
#import "ViewController.h"
@interface ViewController () <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
[UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
NSLog(@"%ld", (long)UIImagePickerControllerSourceTypeCamera); }
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(IBAction)showCameraUI{
UIImagePickerController * pickerController = [[UIImagePickerController alloc]init];
pickerController.mediaTypes = …Run Code Online (Sandbox Code Playgroud) 我有一个照片应用程序,让用户可以拍摄照片或视频,然后如果他们点击"使用照片"或"使用视频"按钮(取决于他们捕获的媒体类型),它会将照片或视频保存到相机胶卷.
这一切都适合拍照,我最初只设置应用程序拍照,但现在我添加了视频,我遇到了问题.我在我的应用程序中设置了一个if语句,用于kUTTypeimage或kUTTypeMovie,但它不喜欢我使用"||" 在我的if语句中用于"或".
它给出了"不兼容的整数到指针转换发送'int'到'NSString*'类型的参数的错误
我不明白为什么它会给我这个错误以及它为什么不让我使用|| 在我的if语句中用于"或".
这是我的ViewController.m文件中的代码块:
- (void)imagePickerController:pickerController didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage || (NSString *)kUTTypeMovie])
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
UIImageWriteToSavedPhotosAlbum(image,nil,nil,nil);
}
[pickerController dismissModalViewControllerAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud) ios ×6
objective-c ×6
iphone ×3
avfoundation ×1
calayer ×1
cgrectmake ×1
facebook ×1
html5 ×1
if-statement ×1
javascript ×1
segue ×1
subview ×1
uiimage ×1
wordpress ×1