小编Dal*_*end的帖子

Xcode 6中的错误 - 视图控制器没有名为(子视图)的插座

我在我的一个应用程序中遇到此错误,并在检查其他一些应用程序后发生同样的错误.我IBOutlets和他们IBActions都不再联系了.当我通过控制拖动到.h文件重新创建插座时,插座仍会在Connections Inspector> Outlets中显示错误,说(视图控制器)没有名为(子视图)的插座.在今天之前我没有这个问题,那么与Xcode 6有关吗?视图控制器引用Identity Inspector> Custom Class下的正确类.我删除了派生数据文件夹,删除了对.h文件的引用,清理了项目,并清理了构建文件夹.这些都没有奏效,在修复此问题之前,我无法继续开发.

奥特莱斯出现感叹号. 注意'easyLabel'

我断开easyLabel,插座消失了. 我无法通过拖放重新连接它.

更新:我刚刚重新开放的项目几天后,我的网点不再有其旁边的感叹号,而"EASYLABEL"出口,我断开再现了.我没有改变任何东西,所以我猜这是Xcode 6-6.1中的一个错误.

更新2:此错误又回来了.每个插座旁边都有惊叹号.如果我删除它们,我无法重新添加它们.无法创建新的网点.也不能给视图控制器一个自定义类.我真的只是想在应用程序上取得一些进展,但这个问题不断出现.真的好不能再忍受了.任何帮助,将不胜感激.

xcode objective-c ios

17
推荐指数
4
解决办法
8728
查看次数

为iPhone 5加载不同的xib

我的应用程序为iPhone 5提供了额外的功能,我为它创建了一个单独的带有.xib的类.我想检测屏幕高度(除非可以获取设备ID /型号)并相应地加载不同的视图控制器.我试过这个:

- (IBAction)select:(id)sender {

CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;

if (screenHeight == 960) {

Selection *selectView =[[Selection alloc] initWithNibName:nil bundle:nil];
selectView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:selectView animated:YES];

}

else {

    Selection_5 *selectView =[[Selection_5 alloc] initWithNibName:nil bundle:nil];
    selectView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:selectView animated:YES];

}

}
Run Code Online (Sandbox Code Playgroud)

Selection和Selection_5是两个不同的类,每个类都有一个用户界面的不同xib.

iphone xcode objective-c ipad ios

8
推荐指数
3
解决办法
7875
查看次数

强迫在风景的照相机视图与方向锁

我正在开发一种增强现实游戏,当设备的方向锁定打开时,我遇到了摄像机视图方向的问题.

我正在使用此代码加载视图内的摄像机视图:

AVCaptureSession *session = [[AVCaptureSession alloc] init];
AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
captureVideoPreviewLayer.frame = self.sessionView.bounds;
[self.sessionView.layer addSublayer:captureVideoPreviewLayer];
CGRect bounds=sessionView.layer.bounds;
captureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
captureVideoPreviewLayer.bounds=bounds;
captureVideoPreviewLayer.orientation = [[UIDevice currentDevice] orientation];
captureVideoPreviewLayer.position=CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds));

AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
// device.position ;
NSError *error = nil;
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error];
if ([device hasTorch]) {
    ([device supportsAVCaptureSessionPreset:AVCaptureSessionPreset1280x720]);
}
else {
    ([device supportsAVCaptureSessionPreset:AVCaptureSessionPreset640x480]);
}
[session addInput:input];
[session startRunning];
Run Code Online (Sandbox Code Playgroud)

为了保持应用程序的横向正确,我只选择了Xcode应用程序摘要中的那个框,其中:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return ((interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}
Run Code Online (Sandbox Code Playgroud)

当设备打开方向锁定(双击主页按钮,向右滑动,点按方向图标)时,摄像机视图处于纵向状态,游戏的其余部分处于横向状态.有没有什么办法解决这一问题?根据我的阅读,当用户打开游戏时,无法关闭方向锁定.

iphone xcode objective-c ipad ios

4
推荐指数
1
解决办法
8888
查看次数

将文本作为字符串共享给另一个应用

我有一个基本上看起来像这样的字符串:

成绩:

球员一:得分
球员两得分
球员三:得分

我想将此作为文本分享给WhatsApp,Facebook,iMessage等应用程序.最好的方法是什么?我曾尝试共享为.txt文件,但它在WhatsApp中作为文件而不是常规消息共享.

objective-c sharing ios

4
推荐指数
2
解决办法
9637
查看次数

使用View Controller作为相机覆盖?

我有一个应用程序,可以加载相机并覆盖按钮以进行点火,重新加载和返回,以及在点击点火和重新加载按钮时动画的png.当摄像机视图加载时,如何将具有按钮和图像的.xib加载视图控制器作为叠加层?

当点击主屏幕上的按钮时,我会加载摄像机视图,用于打开另一个带有按钮和喷枪图像的视图.

下面是我到目前为止所做的,它正在加载相机.我有一个名为PlayViewController的独立视图控制器,接口有一个xib:

-(IBAction)getCameraPicture:(id)sender {


UIImagePickerController *picker = [[UIImagePickerController alloc] init];

picker.sourceType = UIImagePickerControllerSourceTypeCamera;

PlayViewController* overlay = [[PlayViewController alloc] initWithNibName:@"PlayViewController" bundle:nil];
picker.cameraOverlayView = overlay.view;
[picker setDelegate:overlay];
[self presentModalViewController:picker animated:YES];
Run Code Online (Sandbox Code Playgroud)

这是在PlayViewController.m中: code

   #import "PlayViewController.h"
   #import "SoundViewController.h"

@interface PlayViewController ()

@end

@implementation PlayViewControlleriPad...
Run Code Online (Sandbox Code Playgroud)

`

PlayViewController.h:

@interface PlayViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
{

two array declarations...

}

@property (weak, nonatomic) IBOutlet UIButton *reloadButton;
@property (weak, nonatomic) IBOutlet UIButton *fireButton;
@property (weak, nonatomic) IBOutlet UITextField *ammoField;
@property (weak, nonatomic) IBOutlet UIImageView *type;

@end
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c ipad ios

1
推荐指数
1
解决办法
6030
查看次数

减少long for/if语句的长度

我正在尝试制作一个应用程序的代码,我正在开发更高效,更容易阅读.基本上它的作用是从玩家名称的NSUserDefaults中检索一个数组,并用这些名称填充6个文本框(标记为6-11).如果没有现有数组,它将使用另一组名称.任何简化此代码的想法都将受到赞赏.

if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
        NSMutableArray *names = [[NSMutableArray alloc] initWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:@"nameArray"]];
        for (int i = 0; i <= 5; i++) {
            NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
            UITableViewCell *cell = [playerTable cellForRowAtIndexPath:indexPath];

            for (UIView *view in cell.contentView.subviews) {
                if ([view isKindOfClass:[UITextField class]]) {
                    UITextField *txtField = (UITextField *)view;
                    if (txtField.tag == 6) {
                        if([[NSUserDefaults standardUserDefaults] boolForKey:@"customNames"]) {
                            txtField.text = [names objectAtIndex:0]; }
                        else {
                            txtField.text = @"Peter";
                        }
                    }
                    if (txtField.tag == 7) {
                        if([[NSUserDefaults standardUserDefaults] boolForKey:@"customNames"]) …
Run Code Online (Sandbox Code Playgroud)

arrays objective-c

0
推荐指数
1
解决办法
65
查看次数

无法在StreamWriter文件名中使用变量

在写入文本文件时,我在Windows Mobile应用程序中收到错误.我首先创建一个文件名:

filename = "IncomingUnit_" + GlobalVar.getDate() + ".txt";
Run Code Online (Sandbox Code Playgroud)

这将以"IncomingUnit_2017053111:22:57.txt"正确打印到控制台.

然后我使用StreamWriter在该文件中写行.

using (System.IO.StreamWriter writer = new System.IO.StreamWriter(filename, true))
{
    foreach (Record _record in records)
    {
        writer.Write(_record);
    }
}
Run Code Online (Sandbox Code Playgroud)

这给了我一个异常,并且没有创建文件:'mscorlib.dll中出现'System.ArgumentException'类型的第一次机会异常'

如果我取出GlobalVar.GetDate,它会创建文件并写入数据.

filename = "IncomingUnit.txt";
Run Code Online (Sandbox Code Playgroud)

如何将日期插入我的文件名?

.net c# windows-mobile

0
推荐指数
1
解决办法
330
查看次数

标签 统计

objective-c ×6

ios ×5

xcode ×4

ipad ×3

iphone ×3

.net ×1

arrays ×1

c# ×1

sharing ×1

windows-mobile ×1