I'm getting some really strange EXC_BAD_INSTRUCTION only on iPod Touches using route-me. route-me is a library that's in my project.
Here are the details. I'm initWithFrame a Mapview.
mapView = [[RMMapView alloc] initWithFrame:CGRectMake(0, 0, width, height)];
I get an EXC_BAD_INSTRUCTION inside initWithFrame for RMMapView:
- (id)initWithFrame:(CGRect)frame
{ //DEBUGGER STOPS HERE FOR SOME REASON
LogMethod();
if (self = [super initWithFrame:frame]) {
[self performInitialSetup];
}
return self;
}
The debugger just stops on the first {. What's even more strange is that when I view the contents of "frame" instead of being 0,0 for x,and y they are: x = 4.65449901e-10 and y = 3.5698779e-40.
What is going on here? This works fine on any other device.
Anyone have any ideas what could be going on here? I have a feeling it's some project setting that's causing me this. I don't see how the code can be an issue here.
thanks!
I figured it out. Hopefully this is helpful to others:
As I suspected the route-me project settings were incorrect. First I had to change the project to use the same iOS SDK as my main project. I also had to tell it to build ARM6 ARM7 (Standard). It was building only ARM7 (Optimized).
Related
I am new in iOS. I want to use iToast in my App. I followed toast-notifications-ios
First when I created my iToast.m I got four errors on these lines:
[label release];
[imageView release];
view = [v retain];
iToast *toast = [[[iToast alloc] initWithText:_text] autorelease];
I always have problem with release and autorelease in different examples. I use iOS 5.1, xCode 4.3.3. I saw many examples using them but I always got errors on them. Can you let me know why?
When I commented the first third error lines and use the forth one like:
iToast *toast = [[iToast alloc] initWithText:_text];
I could run the project but when the Toast pops up, it never disappears. I used this line as written in README.md:
[[[[iToast makeText:NSLocalizedString(#"Something to display a very long time", #"")]
setGravity:iToastGravityBottom] setDuration:iToastDurationShort] show];
How can I solve this problem?
If you just started out you are probably using Automatic Reference Counting, or ARC. Using this the compiler handles the memory for you and renders retain, release,and autorelease for you. You can either disable ARC for your project or go through the supplied code and make it ARC compliant by translating retains, releases, and autoreleases.
This explains the differences and how to transition:
http://developer.apple.com/library/ios/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html
The application which runs smoothly on 4.0.1 when was tried on run on 4.2.1 produced distorted screen i.e., screen somewhat moved to left by 20%. Phones on which iOS 4.0.1 and 4.2.1 are installed are 2 different phones. What could be the problem?
We observed that wherever we have added as subview this problem is occurring.
Thanks,
Satish
From your description, I think it is either that you are not setting the correct view.autoresizingMask properly or there is a subtle change in how views are being laid out.
Try setting the frame of the view that moved explicitly and see what happens.
[view setFrame:CGRectMake(0, 0, 320, 460)]
Some related piece of code and/or screenshots would definitely help. Also, is it a UIKit application or a Cocos2D game?
EDIT: Since you can't provide code (or a stripped-down example version) I'll just post some code that I've been using.
Usually when I add subviews to "fill" a parent view, I had do the following:
UIView *parent = nil; // find parent view
UIView *child = nil; // child view to add to parent
[parent addSubview:child];
CGRect frame = [parent frame];
frame.origin.x = 0;
frame.origin.y = 0;
[child setFrame:frame];
If you have done that and it still does not work I believe the problem might lies somewhere else (i.e. have you overridden layoutSubviews by any chance? or was the phone jailbroken?)
I highly doubt it'll be a UIKit bug though but it is totally possible.
I believe that I did everything necessary to change my app for ipad (was for iphone at start). I can toggle the build status to either iphone (only), ipad (only) or iphone/ipad - and the app launches either in ipad or iphone simulator. I can do that forth and back at will.
I added the idiom to check for ipad and basically for one of my xib, instead of using the string of my xib to create the controller, I use the one for the ipad. So it is a new xib for ipad with all same graphical objects ( enlarged ;-) ) . I added the callbacks to function correctly with IB.
I can see everything fine and arrive on my new ipad view BUT when I click on one of my buttons... nothing happened like if my callbacks don't work. It is very surprising and actually I have no idea where to look as I compared most of the parameters between my iphone and ipad view and they are identical as far as I can see.
It must be something damn obvious so if one of you had the same issue and it was a very simple answer ... I guess that would be what I missed!
Thanks for your help in advance
Cheers,
geebee
EDIT1: Some code as requested
at start I have that to decide either way:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
examTFVC_NIB=#"ExamTFViewController-iPad";
}
else
{
examTFVC_NIB=#"ExamTFViewController";
}
Then to go to the right view:
ExamTFViewController *examTFViewController = [[ExamTFViewController alloc]
initWithNibName:globals.examTFVC_NIB bundle:nil];
But I have no problem loading the correct XIB. The issue is really the callback functions not being called...
Thanks for the help.
EDIT2:
I also realised that calling the extension of the xib xxx~ipad allows to avoid the example code above. And it works - but still no function can be called.
EDIT3:
IMPORTANT FINDING: if I move my buttons higher and on the left of the screen: they work! So it seems that the functions are called if the event are in the region of an iphone screen although I am on an ipad screen. I guess know it would be more obvious to find the issue! thanks for any help – geebee just now
ANSWER
iPad touch detected only in 320x480 region
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// to correct region size
CGRect rect = [[UIScreen mainScreen] bounds];
[window setFrame:rect];
// now, display your app
[window addSubview:rootController.view];
[window makeKeyAndVisible];
}
** OR OTHER SOLUTION **
Check the full screen at launch checkbox - only present in the ipad xib MainWindow
finally solved - with 2 methods - programmatically or via IB - in the edited section of the post.
I recently updated to Xcode 4.3 and it disabled my UILabels' autoshrink property. I rechecked the boxes in IB and rebuilt the project but it is still cutting off the text. Any suggestions? Is this a known bug? Is there a way to fix this programatically.
I'm seeing the same thing. You can work around it programmatically (I do it in viewDidLoad):
myLabel.adjustsFontSizeToFitWidth = YES;
I had the same problem. Here's the fix, I added it to a utility method, since I have over 100 xibs in my project, and a bunch of them needed fixing. Works great.
Add this to Utility.m:
// UIView+viewRecursion.h
#interface UIView (viewRecursion)
- (NSMutableArray*) allSubViews;
#end
// UIView+viewRecursion.m
#implementation UIView (viewRecursion)
- (NSMutableArray*)allSubViews
{
NSMutableArray *arr=[[NSMutableArray alloc] init];
[arr addObject:self];
for (UIView *subview in self.subviews)
{
[arr addObjectsFromArray:(NSArray*)[subview allSubViews]];
}
return arr;
}
#end
And this:
+(void)fixLabels:(UIView *)theView{
for(UIView *v in [theView allSubViews])
{
if([v isKindOfClass:[UILabel class]])
{
if( !((UILabel*)v).adjustsFontSizeToFitWidth ){
((UILabel*)v).adjustsFontSizeToFitWidth=YES;
// NSLog(#"fixed %#", theView);
}
}
}
}
And then call fixLabels from viewDidLoad for any view that has UILabels that are not auto shrinking:
[Utility fixLabels:self.view];
I have the exact opposite problem! I updated to Xcode 4.3, and now it auto shrinks the text in my tableview cells when I want them to truncate them with the ellipses. I went through the storyboard and modified all of the options that might have to do with that, but it refuses to do what I want. So frustrating.
Edited...
Try and re-create what Xcode was doing to me since it's the reverse of what's happening to you. Highlight the prototype cell you have for your tableview in the storyboard and click on the "Title" and "Subtitle" words. You can find the AutoShrinking property within the attributes inspector, and I suppose you can fix your issue by unchecking this box and rebuilding your app. Very strange how the Xcode upgrade would cause this. It also caused my app to behave a bit strangely (i.e. crashing unexpectedly while running in the simulator), but a few clean and rebuilds solved this. Hopefully you are able to fix this, since I know it was just as frustrating for me!
It just did the same thing to me. All the autoshrink are turned off. Putting back a font size and turning auto shrink on didn't actually work.
I had to fix it programmatically as JLundell suggested.
Xcode 4.3 doesn't respecting the Interface Builder Settings for adjustsFontSizeToFitWidth property.
You can fix it by setting the property value programmatically as JLundell suggested.
myLabel.adjustsFontSizeToFitWidth = YES;
It has been fixed up in 4.3.1
I'm working on an iPhone game using cocos2d and I'm new to Objective C and Cocos2d so I'm sorry if this is a really beginner question. I've done a lot of searching and I can't seem to find a solution for this problem. I've found that cocos2d will not call the dealloc function, release a scene, or a layer unless I put -(void) onExit{self.isTouchEnabled = NO;} at the end of the .m file. The problem is that in the next scene the game crashes when the screen is touched, even if I put self.isTouchEnabled = YES; in the init method, onEntermethod, or anywhere else within the second scene.
When the game crashes (gbd) points to:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
if( dispatchEvents )
[self touches:touches withEvent:event withTouchType:kCCTouchBegan];
}
as the source of the problem stating "EXC_BAD_ACCESS"
Please help!! Thank you!!
I am new to iPhone as well:-) But for my experiences, the reason you get "EXC_BAD_ACCESS" is not because of your code here. it should be "release" problem. i guess you release a released object...
you can try to use Xcode's Zombies instruments to detect where you get this problem. There are heaps of tutorials about Xcode Zombies online, just google it if you want.
good luck:-)