UIView показывает идеально на симуляторе, но не iPhone? - PullRequest
0 голосов
/ 19 марта 2011

Хорошо,

У меня действительно странная проблема. При переключении на другой XIB он отображается на симуляторе, но не на моем тестовом устройстве. Я предоставлю немного кода и скриншоты моего макета в конструкторе интерфейсов! Заранее спасибо.

  • SettingViewController (что вызывается для отображения)
  • DetailViewController (что вызывает SettingsViewController для отображения)

SettingsViewController.h

//
//  SettingsViewController.h
//
//  Created by Coulton Vento on 2/26/11.
//  Copyright 2011 Your Way Websites. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "TableViewAppDelegate.h"
#import "Sqlite.h"

@class SettingsStoreViewController;

@interface SettingsViewController : UIViewController {

}

@end

SettingsViewController.m

#import "SettingsViewController.h"
#import "TableViewAppDelegate.h"

@implementation SettingsViewController

- (void)viewDidLoad {
NSString *myDB = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"flashpics.db"];
database = [[Sqlite alloc] init];
[database open:myDB];

TableViewAppDelegate *dataCeter = (TableViewAppDelegate *)[[UIApplication sharedApplication] delegate];

myTimer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector: @selector(updateNumber) userInfo: nil repeats: YES];

self.navigationItem.title = @"Album Settings";

NSString *post =[NSString stringWithFormat:@"id=%@", dataCeter.dataTwo];
NSString *hostStr = @"http://myflashpics.com/iphone_processes/get_album.php?";
hostStr = [hostStr stringByAppendingString:post];
NSData *dataURL =  [NSData dataWithContentsOfURL: [ NSURL URLWithString: hostStr ]];    
NSString *serverOutput = [[NSString alloc] initWithData:dataURL encoding: NSASCIIStringEncoding];

if ([serverOutput rangeOfString:@"yes"].location == NSNotFound) {
    //NSLog(@"Fail - %@ / %@", usernameField.text, passwordField.text);
    UIAlertView *alertsuccess = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Please check your internet connection" delegate:self cancelButtonTitle:@"Try Again" otherButtonTitles:nil, nil];
    [alertsuccess show];
    [alertsuccess release];
    [alertsuccess setTag:6];
} else {

    NSArray *myWords = [serverOutput componentsSeparatedByString:@"?!?divide?!?"];
    NSString *albumNameResults = [myWords objectAtIndex:1]; 
    NSString *albumCommentsResults = [myWords objectAtIndex:2];
    NSString *albumPrivateResults = [myWords objectAtIndex:3];
    NSString *numberOfConnections = [myWords objectAtIndex:4];

    albumName.text = albumNameResults;

    numberButton.text = numberOfConnections;

    if ([numberOfConnections isEqualToString:@"1"]) {
        connectionsButton.text = @"Connection";
    } else {
        connectionsButton.text = @"Connections";
    }


    if ([albumCommentsResults isEqualToString:@"yes"]) {
        [albumComments setOn:YES animated:YES];
    } else {
        [albumComments setOn:NO animated:YES];
    }

    if ([albumPrivateResults isEqualToString:@"yes"]) {
        [albumPrivate setOn:YES animated:YES];
    } else {
        [albumPrivate setOn:NO animated:YES];
    }
}

}

DetailViewController.h

#import <UIKit/UIKit.h>
#import "Sqlite.h"
#import "OHGridView.h"
#import "BigView.h"
#import "SettingsViewController.h"
#import "processViewController.h"

@class SecondView;
@class BigView;
@class CaptionView;

@interface DetailViewController : UIViewController <OHGridViewDelegate, OHGridViewDataSource> {
}
@end

DetailViewController.m

//
//  DetailViewController.m
//  TableView
//
//  Created by iPhone SDK Articles on 1/17/09.
//  Copyright www.iPhoneSDKArticles.com 2009. 
//

#import "DetailViewController.h"
#import "TableViewAppDelegate.h"
#import "processViewController.h"


@implementation DetailViewController

@synthesize selectedCountry;
@synthesize selectedID;



- (IBAction)switchViews {
[self presentModalViewController:bigView animated:YES];
}


- (void)viewWillAppear {
[(OHGridView *)self.view reloadData];
NSLog(@" --- %@ --- ", items);
}

- (IBAction)showSettings {

TableViewAppDelegate *dataCeter = (TableViewAppDelegate *)[[UIApplication sharedApplication] delegate];
dataCeter.dataTwo = selectedID;

SettingsViewController *screentwothree = [[SettingsViewController alloc] initWithNibName:nil bundle:nil];
screentwothree.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:screentwothree animated:YES];
[screentwothree release];

//[self.navigationController pushViewController:screentwothree animated:YES];
//[screentwothree release];
//screentwothree = nil;
}

/*
 // Override to allow orientations other than the default portrait orientation.
 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
 // Return YES for supported orientations

return (interfaceOrientation == UIInterfaceOrientationPortrait); } * /

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
}


- (void)dealloc {

[selectedCountry release];
[lblText release];
[super dealloc];
}


@end

Извините за весь код.

1 Ответ

2 голосов
/ 19 марта 2011

Подобные вещи часто возникают из-за различий в файловых системах: MacOS обычно не учитывает регистр, а iOS всегда учитывает регистр.Поэтому, если вы указываете .xib как «myview.xib», но его фактическое имя - «MyView.xib», это обычно будет работать на симуляторе, но не на устройстве.То же самое происходит с изображениями и другими ресурсами.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...