Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issues running iOS 5.1 simulator using XCode 4.5

I recently upgraded my XCode to 4.5 version and now I'm having problems when I try to develop applications to iOS 5.0/5.1.

I developed a simple iPad game where the user needs to match images with the correspondent words. All these items are stored in UIImageView, if that is relevant. The supported interface orientation is only landscape.

When I run my application using iPad 6.0 Simulator everything works fine without any problem. But when I try to run it using 5.1, everything goes wrong. The images simply don't appear and my background image appears sideways and repeated. The status bar also appears wrongly: the device orientation is landscape, but the sidebar appears on the right side. This also doesn't happen when I use 6.0 simulator.

In the project details I already changed the iOS Deployment Target to 5.1, as well in the Storyboard. Using iOS 5.1 deployment target the storyboard don't let me to select "Use Autolayout" option, so I deselected this option. Is this caused by this option?

I already tried to run my application in a device, but the result is the same. Since I installed XCode 4.5 I started to have these kind of issues, since for example I can't even run a "Master-detail Application" template properly in iOS 5.x simulator, because it crashes when I click the "Add" button.

Am I missing something to run 5.x applications created using SDK 6? I already searched in a lot of forums but I haven't found any solution to this kind of problem yet. I'll be glad to ear any kind of suggestions, since I already lost lots of time around this issue and I'm running out of options.

[EDIT]: I remembered a detail that maybe can be relevant for this problem: my view in storyboard is a custom view. I created a class that extends from UIView so that I could override drawRect function to draw lines between my objects. Then in Storyboard, in the View, I just selected my class in Custom Class -> Class.

I noticed that when I run 5.1 Simulator the status bar initially appears on the top and then when the window is loaded it goes to the right.

If you want to know any other detail please just ask me.

Thank you very much.

like image 795
fabioalmeida Avatar asked Sep 27 '12 17:09

fabioalmeida


2 Answers

English isn't my native so please forgive my grammar...

As far as your Master-detail "Add" button issue, this is what worked for me.

From what I can tell, the app crashes because of:

[UITableView dequeueReusableCellWithIdentifier:forIndexPath:]: unrecognized selector sent to instance

Quick Help says:

- (id)dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath declaration is only available in iOS (6.0 and later).

So I tried changing the code in MasterViewController.m:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
    [self configureCell:cell atIndexPath:indexPath];
    return cell;
}

for code that Xcode used in older versions:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

    }
    [self configureCell:cell atIndexPath:indexPath];
    return cell;
}

Hope this helps.

like image 98
iv411anna Avatar answered Nov 02 '22 07:11

iv411anna


Have you checked your storyboard to make sure you have shut off Autolayout? Autolayout only works with iOS6. This option can be found when looking at your view controller in the File Inspector Area under Interface Builder Document. It is a checkbox

like image 21
kkirsche Avatar answered Nov 02 '22 06:11

kkirsche