Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-09-2010, 01:59 PM   #1 (permalink)
Registered Member
 
mebarron's Avatar
 
Join Date: Apr 2009
Location: Michigan
Posts: 47
mebarron is on a distinguished road
Default Desired: Touch UIView, use [view addSubview: ] to display a title in a second Navigat

This is the behavior of iPhoto.

Using the code below the second NavBar appears but then I get EXC_BAD_ACCESS.
The results are the same if I uncomment the final line of code to removeFromSuperview
I am stuck. Can you please tell me what I am missing?
Many Thanks, Mark

- (void)touchesEndedNSSet *)touches withEventUIEvent *)event {

UITouch *theTouch = [touches anyObject];

/*
If this is a single tap, and the NavBar is visible ,then disappears
*/

if ([theTouch tapCount] == 1) {
NSTimer* aTimer = [NSTimer scheduledTimerWithTimeInterval: 4.0f target:self
selector:@selector(theTimer userInfo:nil repeats: NO];

[self setNavBar: [[UINavigationBar alloc]
initWithFrame:CGRectMake (0, 0, self.frame.size.width, 44)]];
[[self navBar] setTranslucent:YES];
[[self navBar] setBarStyle:UIBarStyleBlack];
[self setNavItem: [[UINavigationItem alloc] initWithTitle:[photo name]]];

[navBar pushNavigationItem:navItem animated:YES];
[self addSubview:navBar];

[navItem release];
[navBar release];
NSLog(@"Hello from touchesEnded:withEvent:");
}
}

- (void) theTimer: (NSTimer *) timer
{
[timer invalidate];
[timer release];
//[navBar removeFromSuperview];
}

///////
(gdb) break malloc_error_break
Breakpoint 18 at 0x9063c072
(gdb) po aTimer
<NSCFTimer: 0x5b6a2c0>
(gdb) continue
2010-04-09 14:11:36.426 iHungryMePlus-iPad[3167:207] Hello from touchesEnded:withEvent:
(gdb) po timer
<NSCFTimer: 0x5b6a2c0>
(gdb) p(int)[timer retainCount]
$1 = 3
(gdb) p(int)[navBar retainCount]
$2 = 2
(gdb) p(int)[navItem retainCount]
$3 = 2
(gdb) continue
Program received signal: “EXC_BAD_ACCESS”.
(gdb)


Debugger shows
"asm objc_msgSend 0x9191fec0"

Thread-1 -<com.apple.main.thread>
#0 0x9191fed7 in objc_msgSend
#1 0xbfffea2c in ??
#2 0x02b4b943 in CFRunLoopRunSpecific
#3 0x02b4b048 in CFRunLoopRunInMode
#4 0x0315589d in GSEventRunModal
#5 0x03155962 in GSEventRun
#6 0x002f3de1 in UIApplicationMain
#7 0x00002698 in main at main.m:13
mebarron is offline   Reply With Quote
Old 04-09-2010, 02:03 PM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Here's one problem:

Quote:
- (void)invalidate
This method is the only way to remove a timer from an NSRunLoop object. The NSRunLoop object removes and releases the timer, either just before the invalidate method returns or at some later point.
Therefore, you have no need to call [timer release] yourself.
smithdale87 is offline   Reply With Quote
Old 04-09-2010, 09:55 PM   #3 (permalink)
Registered Member
 
mebarron's Avatar
 
Join Date: Apr 2009
Location: Michigan
Posts: 47
mebarron is on a distinguished road
Default Thanks so much that was it!

Quote:
Originally Posted by smithdale87 View Post
Here's one problem:



Therefore, you have no need to call [timer release] yourself.
It was really great of you to take the time to help me out. Many Thanks!:p
mebarron is offline   Reply With Quote
Reply

Bookmarks

Tags
exc_bad_access, ipad, nstimer, simulator 3.2, uinavigationbar

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 312
15 members and 297 guests
chemistry, Domele, Fstuff, givensur, heshiming, HowEver, iAppDeveloper, iphonedevshani, jbro, JoeRCruso, kapps11, newDev, SLIC, stanny, WheyLabs
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,648
Threads: 94,112
Posts: 402,874
Top Poster: BrianSlick (7,990)
Welcome to our newest member, brandon6031
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:26 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0