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 01-09-2010, 05:52 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 41
alexgiul is on a distinguished road
Red face Add Elements to Navigation Bar

Hi,

I have a navigation app and when I start the app, the first view is a table;

on it I have successfully added a "edit" and "about" button following the guide.

Now when I click on "about" I open a new view (derived from UIViewController") and I try to add a new item on the navigation bar to customize the behaviour but the button on this second view doesn't appear...neither the title of the view

I put

Code:
- (void)viewDidLoad {
	
    self.title= @"About"
	
	UIBarButtonItem *settingsButton = [[[UIBarButtonItem alloc] 
									initWithTitle:@"Settings" 
									style:UIBarButtonItemStylePlain 
									target:self 
									action:@selector(openSettings)] autorelease]; 
    
	self.navigationItem.leftBarButtonItem = settingsButton;
	[settingsButton release];
	[super viewDidLoad];
}
Where am I wrong?
alexgiul is offline   Reply With Quote
Old 01-09-2010, 11:34 PM   #2 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Code:
- (void)viewDidLoad {
	
   self.title= @"About"
	
   UIBarButtonItem *settingsButton = [[[UIBarButtonItem alloc] 
      initWithTitle:@"Settings" 
      style:UIBarButtonItemStylePlain 
      target:self 
      action:@selector(openSettings)] autorelease]; 
    
   self.navigationItem.leftBarButtonItem = settingsButton;
   [settingsButton release];
   [super viewDidLoad];
}
Too many releases.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 01-10-2010, 02:50 AM   #3 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 41
alexgiul is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
Code:
- (void)viewDidLoad {
	
   self.title= @"About"
	
   UIBarButtonItem *settingsButton = [[[UIBarButtonItem alloc] 
      initWithTitle:@"Settings" 
      style:UIBarButtonItemStylePlain 
      target:self 
      action:@selector(openSettings)] autorelease]; 
    
   self.navigationItem.leftBarButtonItem = settingsButton;
   [settingsButton release];
   [super viewDidLoad];
}
Too many releases.
I removed the la "release" but nothing change...
could be the problem the type of View hich is a UIViewController?
alexgiul is offline   Reply With Quote
Old 01-10-2010, 08:49 AM   #4 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

How do you go from the first view controller to the second one?
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 01-10-2010, 11:09 AM   #5 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 41
alexgiul is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
How do you go from the first view controller to the second one?
With the code in the previous post
alexgiul is offline   Reply With Quote
Old 01-10-2010, 12:06 PM   #6 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

No you don't. You're creating a button with the previous code. What does the button do?

Hint: Post openSettings
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 01-10-2010, 12:14 PM   #7 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 127
Error404 is on a distinguished road
Default

If you use a navigation bar, you should have your "settingsButton" on the right hand side, becuase the regular back button will be on the right, which might cause problems.

Code:
self.navigationItem.leftBarButtonItem = settingsButton;
Also, try to remove the autorelease and just keep the normal release at the end.
__________________
http://www.innovationdreams.se
Error404 is offline   Reply With Quote
Reply

Bookmarks

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: 334
15 members and 319 guests
akacaj, alexP, ClerurcifeDer, Domele, Duncan C, givensur, GraffitiCircus, JmayLive, michelle, NetGuru, NSString, Paul Slocum, Sloshmonster, soohyun, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,650
Threads: 94,114
Posts: 402,883
Top Poster: BrianSlick (7,990)
Welcome to our newest member, soohyun
Powered by vBadvanced CMPS v3.1.0

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