App Crashing on keyboard showing or hiding ios iphone - iphone

Working on an application and using resignFirstResponder method for edittext.
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
return YES;
}// return NO to disallow editing.
- (void)textFieldDidBeginEditing:(UITextField *)textField {
CGPoint scrollPoint = CGPointMake(0, textField.frame.origin.y);
[scrollView setContentOffset:scrollPoint animated:YES];
}// became first responder
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField {
return YES;
}// return YES to allow editing to stop and to resign first responder status. NO to disallow the editing session to end
- (void)textFieldDidEndEditing:(UITextField *)textField {
[scrollView setContentOffset:CGPointZero animated:YES];
}// may be called if forced even if shouldEndEditing returns NO (e.g. view removed from window) or endEditing:YES called
- (BOOL)textFieldShouldClear:(UITextField *)textField {
return NO;
}// called when clear button pressed. return NO to ignore (no notifications)
-(BOOL)textFieldShouldReturn:(UITextField*)textField;
{
NSInteger nextTag = textField.tag + 1;
// Try to find next responder
UIResponder* nextResponder = [textField.superview viewWithTag:nextTag];
if (nextResponder) {
// Found next responder, so set it.
[nextResponder becomeFirstResponder];
} else {
// Not found, so remove keyboard.
[textField resignFirstResponder];
}
return NO; // We do not want UITextField to insert line-breaks.
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
if ([emailField isFirstResponder] && [touch view] != emailField) {
[emailField resignFirstResponder];
}
else if ([passwordField isFirstResponder] && [touch view] != passwordField) {
[passwordField resignFirstResponder];
}
[super touchesBegan:touches withEvent:event];
}
I have been looking into for so long.. But app crashes on random. Sometimes runs smooth and sometimes it get crashed right after I tap on any UIEdittext..
Please help. I have also tried: How to resign first responder from text field when user tap elsewhere?
but it also crashes in dismiss keyboard method on random cases. Can't find that..
Please help.
Device Log
Oct 8 19:09:28 iPhone-5 wifid[15] <Notice>: WiFi:[402934168.667607]:
Oct 8 19:09:28 iPhone-5 wifid[15] <Notice>: Too frequent(0.169014 secs) rssi event from driver, ignoring
Oct 8 19:09:28 iPhone-5 wifid[15] <Notice>:
Oct 8 19:09:36 iPhone-5 wifid[15] <Notice>: WiFi:[402934176.114689]: WiFiLocaleManagerCheckLocale: trying to determine locale...
Oct 8 19:09:36 iPhone-5 wifid[15] <Notice>: WiFi:[402934176.115691]: WiFiManagerCoreLocationGetCachedLocation: getting cached location...
Oct 8 19:09:36 iPhone-5 wifid[15] <Notice>: WiFi:[402934176.119252]: __WiFiLocaleManagerGetLocaleFromMcc: finding iso country code for mcc 410 ....
Oct 8 19:09:36 iPhone-5 wifid[15] <Notice>: WiFi:[402934176.119628]: Starting Low Accuracy Location Monitoring, locationMonitoringTimeout=60.000000
Oct 8 19:09:36 iPhone-5 wifid[15] <Notice>: WiFi:[402934176.120057]: WiFiManagerCoreLocationStartLocationUpdates: starting location updates...
Oct 8 19:09:36 iPhone-5 wifid[15] <Notice>: WiFi:[402934176.120356]: Location Monitoring successfully started with accuracy=3000.000000meters
Oct 8 19:09:36 iPhone-5 wifid[15] <Notice>: WiFi:[402934176.120673]: __WiFiLocationServiceManagerEventCallback, got cb dict <dictionary> {
Oct 8 19:09:36 iPhone-5 wifid[15] <Notice>: eventType : 0
Oct 8 19:09:36 iPhone-5 wifid[15] <Notice>: location : <+33.53914677,+73.10165631> +/- 1414.00m (speed -1.00 mps / course -1.00) # 10/8/13, 7:09:36 PM Pakistan Standard Time
Oct 8 19:09:36 iPhone-5 wifid[15] <Notice>: }
Oct 8 19:09:36 iPhone-5 wifid[15] <Notice>: WiFi:[402934176.124702]: __WiFiLocationServiceManagerProcessLocationAvailableEvent: isValidHighAccuracyLocation 0, isValidLowAccuracyLocation 1
Oct 8 19:09:36 iPhone-5 wifid[15] <Notice>: WiFi:[402934176.125013]: __WiFiLocationServiceManagerProcessLocationAvailableEvent: give low accuracy callback
Oct 8 19:09:36 iPhone-5 wifid[15] <Notice>: WiFi:[402934176.125276]: __WiFiLocaleManagerGetLocaleFromLocation: <+33.53914677,+73.10165631> +/- 1414.00m (speed -1.00 mps / course -1.00) # 10/8/13, 7:09:36 PM Pakistan Standard Time
Oct 8 19:09:36 iPhone-5 wifid[15] <Notice>: WiFi:[402934176.127336]: locale from bounding box
Oct 8 19:09:36 iPhone-5 wifid[15] <Notice>: WiFi:[402934176.127564]: new locale: , locale:
Oct 8 19:09:36 iPhone-5 wifid[15] <Notice>: WiFi:[402934176.127795]: Stopping Low Accuracy Location Monitoring
Oct 8 19:09:36 iPhone-5 wifid[15] <Notice>: WiFi:[402934176.128050]: Location Monitoring stopped
Oct 8 19:09:36 iPhone-5 wifid[15] <Notice>: WiFi:[402934176.128296]: WiFiManagerCoreLocationStopLocationUpdates: stopping location updates...
Oct 8 19:09:36 iPhone-5 wifid[15] <Notice>: WiFi:[402934176.128696]: Stopping Low Accuracy Location Monitoring
Oct 8 19:09:36 iPhone-5 wifid[15] <Notice>: WiFi:[402934176.128949]: CLMonitoring is already stopped
Oct 8 19:09:37 iPhone-5 wifid[15] <Notice>: WiFi:[402934177.474861]:
Oct 8 19:09:37 iPhone-5 wifid[15] <Notice>: Too frequent(3.971344 secs) rssi event from driver
Oct 8 19:09:37 iPhone-5 wifid[15] <Notice>:
Oct 8 19:09:38 iPhone-5 wifid[15] <Notice>: WiFi:[402934178.504655]:
Oct 8 19:09:38 iPhone-5 wifid[15] <Notice>: Too frequent(1.029793 secs) rssi event from driver
Oct 8 19:09:38 iPhone-5 wifid[15] <Notice>:
Oct 8 19:09:58 iPhone-5 wifid[15] <Notice>: WiFi:[402934198.509395]:
Oct 8 19:09:58 iPhone-5 wifid[15] <Notice>: Too frequent(4.996233 secs) rssi event from driver
Oct 8 19:09:58 iPhone-5 kernel[0] <Debug>: AppleD1972PMUPowerSource: limiting USB input current to 490 mA (measured 496 mA)
Oct 8 19:09:58 iPhone-5 kernel[0] <Debug>: AppleD1972PMUPowerSource: limiting USB input current to 390 mA (measured 468 mA)
Oct 8 19:09:58 iPhone-5 kernel[0] <Debug>: 086669.986712 wlan.A[10295] AppleBCMWLANNetManager::updateLinkQualityMetrics(): Report LQM to User Land 100, fAverageRSSI -70
Oct 8 19:09:58 iPhone-5 wifid[15] <Notice>:

Related

My App Crashed when trying to get Contents Of URL

my app crashed when nsstring getting contents of URL.
website = [NSString stringWithFormat:#"hidden."];
contents = [NSString stringWithContentsOfURL:[NSURL URLWithString:website] encoding:NSUTF8StringEncoding error:nil];
the crash log is:
void _WebThreadLockFromAnyThread(bool), 0x865cc40: Obtaining the web lock from a thread other than the main thread or the web thread. UIKit should not be called from a secondary thread.
2012-07-10 11:15:17.654 MyApplication[1505:19407] OK // some output
2012-07-10 11:15:17.660 MyApplication[1505:19407] bool _WebTryThreadLock(bool), 0x865cc40: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...
1 WebThreadLock
2 -[UITextRangeImpl isEmpty]
3 -[UITextRange(UITextSelectionAdditions) _isCaret]
4 -[UITextSelectionView setCaretBlinks:]
5 -[UIKeyboardImpl setCaretBlinks:]
6 -[UIKeyboardImpl setDelegate:force:]
7 -[UIKeyboardImpl setDelegate:]
8 -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:]
9 -[UIResponder(UIResponderInputViewAdditions) reloadInputViews]
10 -[UIResponder(Internal) _windowBecameKey]
11 -[UITextField _windowBecameKey]
12 -[UIWindow makeKeyWindow]
13 -[UIWindow makeKeyAndVisible]
14 -[MyApplicationAppDelegate checkLogin]
15 -[NSThread main]
16 __NSThread__main__
17 _pthread_start
18 thread_start
the code is called with [self performSelectorInBackground:#selector(checkLogin) withObject:nil]; from IBAction. what i am doing wrong?
(Xcode 4.3, Mac OS X Lion, iPhone Simulator 5.1)
According to that error message, you're trying to update a UIKit object from a background thread, and the UI can only be updated from the main thread.
Instead, use self performSelectorOnMainThread to call back to the main thread to update your UI with whatever information you received when your web call returns.
From your main thread:
[self performSelectorInBackground:#selector(checkLogin) withObject:nil];
In the background:
- (void)checkLogin {
// Do web stuff
...
[self performSelectorOnMainThread:#selector(updateUI)
withObject:nil
waitUntilDone:NO];
}
- (void)updateUI {
[statusLabel setText:#"Done!"];
}
Try using
- (id)performSelector:(SEL)aSelector withObject:(id)anObject.

UITextView textViewShouldBeginEditing crashes when tapped more than once

I have a UIViewController. In this controller I programmatically create a UITextView and set its delegate as my controller. I do this because I dont want to start editing the textView when I tap it.
ViewDidLoad method
UITextView* textView = [[UITextView alloc] initWithFrame:CGRectMake(9, 10, 302, 200)];
[textView setDelegate:self];
[self.view addSubview:textView];
[textView release];
I implemented the textViewShouldBeginEditing method to return NO here to disable the keyboard from showing up.
textViewShouldBeginEditing method
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
NSLog(#"Shouldbegin");
return NO;
}
The problem that appears
When I tap the textView it works once, but if i tap it again it will crash the application without any log. The weird thing when I hold the textView and release it, it will work like I want it to work. A normal single tap on the other hand doesn't work a second time.
Edit
Single tapping quickly after each other also seems to work, so it seems that it wont work after i wait x seconds.
After some testing I found out it seems to be an iOS 5.X > bug. When running my App in a 4.3 device/simulator it works like it should. The error log on a iOS 5.1 device says the following:
Date/Time: 2012-04-17 14:00:49.497 +0200
OS Version: iPhone OS 5.1 (9B176)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000014
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 TextInput 0x36bf69e8 TI::Favonius::BeamSearch::choose_hit_test_node(WTF::RefPtr<TI::Favonius::SearchNode> const&, WTF::RefPtr<TI::Favonius::KeyAreaNode> const&, WTF::RefPtr<TI::Favonius::SearchNode> const&, WTF::RefPtr<TI::Favonius::SearchNode> const&) + 12
1 TextInput 0x36bf6d1e TI::Favonius::BeamSearch::update_for_touch(unsigned int, WTF::PassRefPtr<TI::Favonius::KeyAreaNode>) + 602
2 TextInput 0x36bfb5c2 TI::Favonius::StrokeBuildManager::update_search_for_touch(unsigned int, int) + 66
3 TextInput 0x36bfb97c TI::Favonius::StrokeBuildManager::key_down_or_drag_hit_test_for_UI(bool, CGPoint, double, int, int, float, bool, ZT::LayoutDictionaryContext&, bool, int) + 216
4 TextInput 0x36bddf54 TIInputManagerZephyr::simulate_touches_for_input_string() + 344
5 TextInput 0x36bed8ba -[TIKeyboardInputManagerZephyr candidates] + 214
6 UIKit 0x31066616 -[UIKeyboardImpl generateAutocorrectionReplacements:] + 82
7 UIKit 0x31108a96 __71-[UITextInteractionAssistant scheduleReplacementsForRange:withOptions:]_block_invoke_0 + 370
8 UIKit 0x3110ec62 -[UITextSelectionView calculateAndShowReplacements:] + 6
9 Foundation 0x3762192c __NSFireDelayedPerform + 408
10 CoreFoundation 0x361a1a2c __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8
11 CoreFoundation 0x361a1692 __CFRunLoopDoTimer + 358
12 CoreFoundation 0x361a0268 __CFRunLoopRun + 1200
13 CoreFoundation 0x3612349e CFRunLoopRunSpecific + 294
14 CoreFoundation 0x36123366 CFRunLoopRunInMode + 98
15 GraphicsServices 0x324e3432 GSEventRunModal + 130
16 UIKit 0x30e70e76 UIApplicationMain + 1074
I did find a solution. I don't really like working around Apple bugs but sometimes you have to. It is three steps...
1) replace the default keyboard with an invisible view
- (void)viewDidLoad
{
[super viewDidLoad];
myTextView.inputView = customKeyboard;
}
2) answer YES to allow editing
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
return YES;
}
3) In textViewDidChangeSelection resign the first responder to hide the cursor
- (void)textViewDidChangeSelection:(UITextView *)textView{
[textView resignFirstResponder];
}
If you don't want to start editing of UITextView when you tapped it:
UITextView* textView = ...;
textView.editable = NO;
After some testing I found out it seems to be an iOS 5.X > bug. When running my App in a 4.3 device/simulator it works like it should.
Look in my main post where i edited the logfile.
-(BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
[txtView resignFirstResponder];
}
and release txtView in dealloc method
Swift 4.2
The best and easy way to solve this just make undo manager as false
textView.undoManager?.disableUndoRegistration()
This error appears if you have change the view at run time like within the table, and cell will be reloaded on tapping,

Cocos2D crashing on iPhone immediately but not in simulator

I'm trying to test a Cocos2D app on an iPhone, and get this crash that I copied from the console:
cocos2d: CCSpriteFrameCache: Trying to use file 'heroTestSheet.png' as texture
cocos2d: CCTexture2D. Can't create Texture. UIImage is nil
cocos2d: Couldn't add image:heroTestSheet.png in CCTextureCache
cocos2d: CCSpriteFrameCache: Couldn't load texture
cocos2d: CCTexture2D. Can't create Texture. UIImage is nil
cocos2d: Couldn't add image:heroTestSheet.png in CCTextureCache
cocos2d: CCSpriteFrameCache: Frame 'heroFrame1.png' not found
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSMutableArray insertObject:atIndex:]: attempt to insert nil object at 0'
*** Call stack at first throw:
(
0 CoreFoundation 0x3759dc7b __exceptionPreprocess + 114
1 libobjc.A.dylib 0x32d9bee8 objc_exception_throw + 40
2 CoreFoundation 0x3752a951 -[__NSArrayM insertObject:atIndex:] + 136
3 CoreFoundation 0x3752a8bf -[__NSArrayM addObject:] + 34
4 cocosTests 0x0000ce28 -[HeroClass init] + 1544
5 cocosTests 0x0000304c -[DebugZoneLayer init] + 860
6 cocosTests 0x00074e04 +[CCNode node] + 76
7 cocosTests 0x0000c4e4 -[DebugZoneScene init] + 244
8 cocosTests 0x00074e04 +[CCNode node] + 76
9 cocosTests 0x0000c390 +[DebugZoneScene scene] + 100
10 cocosTests 0x00002540 -[cocosTestsAppDelegate applicationDidFinishLaunching:] + 1028
11 UIKit 0x3592502c -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1200
12 UIKit 0x3591ea78 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 396
13 UIKit 0x358d82e4 -[UIApplication handleEvent:withNewEvent:] + 1476
14 UIKit 0x358d7b1c -[UIApplication sendEvent:] + 68
15 UIKit 0x358d73b4 _UIApplicationHandleEvent + 6824
16 GraphicsServices 0x33e77c88 PurpleEventCallback + 1048
17 CoreFoundation 0x3752f5cb __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 28
18 CoreFoundation 0x3752f589 __CFRunLoopDoSource1 + 164
19 CoreFoundation 0x37521835 __CFRunLoopRun + 580
20 CoreFoundation 0x3752150b CFRunLoopRunSpecific + 226
21 CoreFoundation 0x37521419 CFRunLoopRunInMode + 60
22 UIKit 0x3591d554 -[UIApplication _run] + 548
23 UIKit 0x3591a558 UIApplicationMain + 972
24 cocosTests 0x000020c4 main + 100
25 cocosTests 0x0000205c start + 40
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found).
Running it in the simulator runs fine, but I still get this message in the console when it starts up "CCSpriteFrameCache: Trying to use file 'heroTestSheet.png' as texture"
I suspect that's where the problem starts. Maybe I'm just understanding how my code for my hero sprite subclass should be written. I thought heroTestSheet.png was the texture it was relying on to split up into other images referencing the plist.
Here's my init in my hero subclass:
-(id) init{
self = [super init];
if (!self) {
return nil;
}
_collisWidthFromCtr = 16;
_collisHeightFromCtr = 16;
_collisPushPointsNums = 5;
_travelRectCenterPoints = [[NSMutableArray alloc] init];
_collisPushPoints = [[NSMutableArray alloc] init];
[_collisPushPoints insertObject:[NSValue valueWithCGPoint:CGPointMake( _collisWidthFromCtr, _collisHeightFromCtr)] atIndex:0];
[_collisPushPoints insertObject:[NSValue valueWithCGPoint:CGPointMake( _collisWidthFromCtr, 0)] atIndex:1];
[_collisPushPoints insertObject:[NSValue valueWithCGPoint:CGPointMake( _collisWidthFromCtr,-_collisHeightFromCtr)] atIndex:2];
[_collisPushPoints insertObject:[NSValue valueWithCGPoint:CGPointMake( 0, _collisHeightFromCtr)] atIndex:3];
[_collisPushPoints insertObject:[NSValue valueWithCGPoint:CGPointMake(-_collisWidthFromCtr, _collisHeightFromCtr)] atIndex:4];
_rectCheckRes = 32;
_speed = 8;
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:#"heroTestSheet.plist"];
_heroSpriteSheet = [CCSpriteBatchNode batchNodeWithFile:#"heroTestSheet.png"];
//[self addChild:_heroSpriteSheet];
NSMutableArray *heroSpriteFlyAnimFrames = [NSMutableArray array];
for(int i = 1; i <= 2; ++i) {
[heroSpriteFlyAnimFrames addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:#"heroFrame%d.png", i]]];
}
CCAnimation *heroSpriteFlyAnim = [CCAnimation animationWithFrames:heroSpriteFlyAnimFrames delay:0.03f];
_heroSprite = [CCSprite spriteWithSpriteFrameName:#"heroFrame1.png"];
_heroSpriteFlyAction = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:heroSpriteFlyAnim restoreOriginalFrame:NO]];
[_heroSprite runAction:_heroSpriteFlyAction];
[_heroSpriteSheet addChild:_heroSprite];
return self;
}
Please excuse me if I'm being unclear, so let me know any other info I need to provide. Just posting this for now because I don't know where else to start to solve it and what other info I should provide, and it might be obvious to some other cocos devs whats wrong from what I posted. Thanks
The simulator can be more forgiving than the device. Double check that your file name really is "heroTestSheet.png" and not "HeroTestSheet.png" for example. It is case sensitive on your device.
Figured it out.. it was just the heroTestSheet.png it was trying to use was somehow invalid. I exported in an older photoshop, but I'm not really positive what settings it had. I exported it again from a newer photoshop without any color mange settings, and now it works fine!
I think you image was not added on the project.
You must copy your binary to the resource.
select your target and then select the build phases then copy bundle resource
add you image on that content.
I think it will work.

iAd error how to resolve it?

i add iAd into UIVIew at buttom of TableView, it also error when fast scroll up/down.
Code
- (void)viewDidLoad {
//NSLog(#"viewDidLoad");
if(NSClassFromString(#"ADBannerView") != nil) {
ADBannerView *adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0,0,0,0)];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
adView.delegate = self;
adView.hidden = YES;
[self.iAdBanner addSubview:adView];
[UIView beginAnimations:#"animateAdBannerOff" context:NULL];
// assumes the banner view is at the top of the screen.
adView.frame = CGRectOffset(adView.frame, 0, -150);
[UIView commitAnimations];
//[adView release];
}
else {
//NSLog(#"iad not available");
}
[super viewDidLoad];
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
//NSLog(#"bannerViewDidLoadAd");
//[self moveBannerViewOnscreen];
if (banner.hidden)
{
[UIView beginAnimations:#"animateAdBannerOn" context:NULL];
// assumes the banner view is offset 50 pixels so that it is not visible.
banner.frame = CGRectOffset(banner.frame, 0, 150);
banner.hidden = NO;
[UIView commitAnimations];
//self.bannerIsVisible = YES;
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
//NSLog(#"bannerView error");
//[self moveBannerViewOffscreen];
//*
if (!banner.hidden)
{
[UIView beginAnimations:#"animateAdBannerOff" context:NULL];
// assumes the banner view is at the top of the screen.
banner.frame = CGRectOffset(banner.frame, 0, -150);
[UIView commitAnimations];//*/
banner.hidden = YES;
}
}
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave {
//NSLog(#"bannerViewActionShouldBegin");
//[super bannerViewActionShouldBegin:banner willLeaveApplication:willLeave];
return YES;
}
- (void)bannerViewActionDidFinish:(ADBannerView *)banner {
//NSLog(#"bannerViewActionDidFinish");
}
Error Log
2010-07-27 11:58:58.547 PantipCafe[730:307] ******* Accessibility Status Changed: On
2010-07-27 11:58:59.068 PantipCafe[730:307] ********** Loading AX for: com.ragopor.pantip ************
2010-07-27 11:59:01.345 PantipCafe[730:307] CPDistributedMessagingCenter attempting to send reply to a dead port. Reply keys: (null)
2010-07-27 11:59:05.182 PantipCafe[730:307] CPDistributedMessagingCenter attempting to send reply to a dead port. Reply keys: (null)
2010-07-27 11:59:11.653 PantipCafe[730:307] CPDistributedMessagingCenter attempting to send reply to a dead port. Reply keys: (null)
2010-07-27 11:59:13.224 PantipCafe[730:307] CPDistributedMessagingCenter attempting to send reply to a dead port. Reply keys: (null)
2010-07-27 11:59:25.437 PantipCafe[730:307] CPDistributedMessagingCenter attempting to send reply to a dead port. Reply keys: (null)
2010-07-27 11:59:28.434 PantipCafe[730:307] CPDistributedMessagingCenter attempting to send reply to a dead port. Reply keys: (null)
2010-07-27 12:00:06.220 PantipCafe[730:307] CPDistributedMessagingCenter attempting to send reply to a dead port. Reply keys: (null)
2010-07-27 12:00:10.241 PantipCafe[730:307] -[__NSCFType bannerView:didFailToReceiveAdWithError:]: unrecognized selector sent to instance 0x544e9b0
2010-07-27 12:00:10.265 PantipCafe[730:307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType bannerView:didFailToReceiveAdWithError:]: unrecognized selector sent to instance 0x544e9b0'
*** Call stack at first throw:
(
0 CoreFoundation 0x3303ffd3 __exceptionPreprocess + 114
1 libobjc.A.dylib 0x309e7871 objc_exception_throw + 24
2 CoreFoundation 0x33043a77 -[NSObject(NSObject) doesNotRecognizeSelector:] + 102
3 CoreFoundation 0x33042f15 ___forwarding___ + 508
4 CoreFoundation 0x32fd5680 _CF_forwarding_prep_0 + 48
5 iAd 0x31bdc25d -[ADBannerView _sanitizeAndForwardErrorToDelegate:] + 48
6 iAd 0x31bdafcf -[ADBannerView sessionBannerViewDidFailToReceiveAd:withError:] + 38
7 iAd 0x31be8ca9 -[ADSession bannerViewDidFailToReceiveAddWithErrorMessage:userInfo:auditToken:] + 116
8 AppSupport 0x32a4d0b5 -[CPDistributedMessagingCenter _dispatchMessageNamed:userInfo:reply:auditToken:] + 172
9 AppSupport 0x32a4df87 processMessage + 514
10 AppSupport 0x32a4e1cb _CPDMMessage + 74
11 AppSupport 0x32a4ede9 _XMessage + 248
12 AppSupport 0x32a412c3 migHelperRecievePortCallout + 138
13 CoreFoundation 0x33015aab __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
14 CoreFoundation 0x3301784f __CFRunLoopDoSource1 + 166
15 CoreFoundation 0x3301862d __CFRunLoopRun + 520
16 CoreFoundation 0x32fc18eb CFRunLoopRunSpecific + 230
17 CoreFoundation 0x32fc17f3 CFRunLoopRunInMode + 58
18 GraphicsServices 0x302dd673 GSEventRunModal + 114
19 GraphicsServices 0x302dd71f GSEventRun + 62
20 UIKit 0x33720cff -[UIApplication _run] + 402
21 UIKit 0x3371f8c7 UIApplicationMain + 670
22 PantipCafe 0x00002ceb main + 42
23 PantipCafe 0x00002c88 start + 52
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
(gdb)
Might be easier to answer with your header file, but did you set the interface to implement the delegate interface? You need to do that in your UIViewController in order to capture the iAd messages. And don't forget to #import .
If you set things up with Interface Builder -- and AFAICT you didn't and just create the iAd on the fly -- then there are other issues with setting your iAd delegate to your view which you do by connecting the iAd delegate to the "File's Owner" socket.
Anyway, check your header file and I hope this helps you both.

CGContextFillEllipseInRect: invalid context

when I launch my app, I keep getting this CGContextFillEllipseInRect: invalid context error. My app is simply to make the circle 'pinchable'.
The debugger shows me this:
[Session started at 2010-05-23 18:21:25 +0800.]
2010-05-23 18:21:27.140 Erase[8045:207] I'm being redrawn.
Sun May 23 18:21:27 Sidwyn-Kohs-MacBook-Pro.local Erase[8045] <Error>: CGContextFillEllipseInRect: invalid context
2010-05-23 18:21:27.144 Erase[8045:207] New value of counter is 1
2010-05-23 18:21:27.144 Erase[8045:207] I'm being redrawn.
Sun May 23 18:21:27 Sidwyn-Kohs-MacBook-Pro.local Erase[8045] <Error>: CGContextFillEllipseInRect: invalid context
2010-05-23 18:21:27.144 Erase[8045:207] New value of counter is 2
2010-05-23 18:21:27.144 Erase[8045:207] I'm being redrawn.
Sun May 23 18:21:27 Sidwyn-Kohs-MacBook-Pro.local Erase[8045] <Error>: CGContextFillEllipseInRect: invalid context
2010-05-23 18:21:27.144 Erase[8045:207] New value of counter is 3
2010-05-23 18:21:27.145 Erase[8045:207] I'm being redrawn.
Sun May 23 18:21:27 Sidwyn-Kohs-MacBook-Pro.local Erase[8045] <Error>: CGContextFillEllipseInRect: invalid context
2010-05-23 18:21:27.145 Erase[8045:207] New value of counter is 4
2010-05-23 18:21:27.148 Erase[8045:207] I'm being redrawn.
Sun May 23 18:21:27 Sidwyn-Kohs-MacBook-Pro.local Erase[8045] <Error>: CGContextFillEllipseInRect: invalid context
2010-05-23 18:21:27.149 Erase[8045:207] New value of counter is 5
2010-05-23 18:21:27.150 Erase[8045:207] I'm being redrawn.
Sun May 23 18:21:27 Sidwyn-Kohs-MacBook-Pro.local Erase[8045] <Error>: CGContextFillEllipseInRect: invalid context
2010-05-23 18:21:27.150 Erase[8045:207] New value of counter is 6
My implementation file is:
//
// ImageView.m
// Erase
//
#import "ImageView.h"
#import "EraseViewController.h"
#implementation ImageView
-(void)setNewRect:(CGRect)anotherRect{
newRect = anotherRect;
}
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
newRect = CGRectMake(0,0,0,0);
ref = UIGraphicsGetCurrentContext();
}
return self;
}
- (void)drawRect:(CGRect)rect {
static int counter = 0;
CGRect veryNewRect = CGRectMake(30.0, 210.0, 60.0, 60.0);
NSLog(#"I'm being redrawn.");
if (counter == 0){
CGContextFillEllipseInRect(ref, veryNewRect);
}
else{
CGContextFillEllipseInRect(ref, rect);
}
counter++;
NSLog(#"New value of counter is %d", counter);
}
- (void)setNeedsDisplay{
[super setNeedsDisplay];
[self drawRect:newRect];
}
- (void)dealloc {
[super dealloc];
}
#end
I've got two questions:
1) Why is it updating counter 6 times? I removed the line [super setNeedsDisplay]; but it becomes 4 times.
2) What is that invalid context error?
Thanks guys.
I'm not sure about the six calls, but at least two calls are happening because the framework is calling drawRect: and so are you. You don't need to call drawRect: yourself (and hence you don't need to override setNeedsDisplay:).
You should call UIGraphicsGetCurrentContext from inside drawRect:. Don't cache it. It may be failing because the framework doesn't guarantee to use the same context on each call, or because you are calling drawRect: directly, or both; I'm not sure which.