1

更新 0

この質問への回答は控えてください。

問題の一部を見つけたと思います。

で作成した自動生成された .xib ファイルの名前_を使用するように変更しようとすると、XCode が再び異常終了しました~。Xcode は、中止時に少なくとも 1 つの .xib ファイルを破棄するように見えます。そのファイルには、アプリに必要な最小限のビューまたはウィンドウ オブジェクトが含まれています。不足している .xib ファイルは Finder から削除されますが、ナビゲーターには引き続き表示されます。

そのため、ファイルをそのままにして_再試行しますが、以前に得た提案は使用しません。

更新 0

ここで推奨されているように、xibs が次のコードを変更したことに問題があります。 問題は、xib 名を「_」の代わりに「~」を使用するように変更し、xib 名を参照する対応するコードを修正できないことが原因であると思われます。

問題は、Xcode を混乱させる可能性のある次の 4 つのファイル名を持っている可能性もありますか?

BSViewController.h/.m

BSViewController~iPhone.xib

BSViewController~iPad.xib

元のコード.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        self.viewController = [[BSViewController alloc] initWithNibName:@"BSViewController_iPhone" bundle:nil];
    } else {
        self.viewController = [[BSViewController alloc] initWithNibName:@"BSViewController_iPad" bundle:nil];
    }
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}

改変コード(おまけ含む)

#import "BSAppDelegate.h"

#import "BSViewController.h"
@implementation BSAppDelegate
@synthesize window;
@synthesize viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.viewController = [[BSViewController alloc] initWithNibName:@"BSViewController" bundle:nil];
    [self.window addSubview:viewController.view];
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}

BSAppDelegate.h が続きます。

#import <UIKit/UIKit.h>

@class BSApp;
@class BSViewController;
@interface BSAppDelegate : NSObject <UIApplicationDelegate>{
    UIWindow *window;
    BSViewController *viewController;
}
@property (retain, nonatomic) IBOutlet UIWindow *window;
@property (retain, nonatomic) IBOutlet BSViewController *viewController;
@end

BSViewController.h が続きます。

#import <UIKit/UIKit.h>

@interface BSViewController : UIViewController<UIImagePickerControllerDelegate, UINavigationControllerDelegate> {
    UIImage *workingImage;
    IBOutlet UIImageView *imageView;
}

@property (nonatomic, retain) UIImage *workingImage;
@property (nonatomic, retain) IBOutlet UIImageView *imageView;

+ (BOOL)isCameraDeviceAvailable;
- (IBAction) chooseImage:(id) sender;
- (IBAction) grayscale:(id) sender;

@end

BSViewController.m が続きます。

#import "BSViewController.h"

@interface BSViewController ()

@end

@implementation BSViewController

@synthesize imageView;
@synthesize workingImage;

+(BOOL)isCameraDeviceAvailable
{
    BOOL isCameraAvailable=NO;
    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {
        if([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront] )
            isCameraAvailable = YES;
    }
    return isCameraAvailable;
}

- (IBAction) chooseImage:(id) sender {
    [self.view addSubview: self.imageView];
    UIImage* testCard = [UIImage imageNamed:@"ipad 7D.JPG"];
    CGImageRef num = CGImageCreateWithImageInRect([testCard CGImage],CGRectMake(532, 0, 104, 104));
    UIGraphicsBeginImageContext(CGSizeMake( 250,650));
    CGContextRef con = UIGraphicsGetCurrentContext();
    CGContextDrawImage(con, CGRectMake(0, 0, 13, 13) ,num);
    UIImage* im = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    CGImageRelease(num);
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    self.workingImage = [info objectForKey:UIImagePickerControllerOriginalImage];
    [imageView setImage:self.workingImage];
    [picker dismissViewControllerAnimated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
    self.imageView = nil;
}
- (void)dealloc {
    [workingImage release];
    [imageView release];
    [super dealloc];
}

@end

Xcode 4.5.2 を使用し、iOS 6 向けに設計しています。

BSViewController~iPad.xibは、コントロールをクリックすると「searchDisplayController」と「view」の2つのアウトレットを生成する「ViewController」オブジェクトを追加しました。「ビュー」の最上位オブジェクトはありません。「+」を「ファイルの所有者」にドラッグしようとすると、結果が得られず、おそらくそうすべきではありません。

BSViewController~iPhone.xibはすでに「ウィンドウ」オブジェクトを持っていますが、それが良いのか、〜iPad.xibにも追加する必要があるのか​​ わかりません(しかし、方法はわかりません)。

4

0 に答える 0