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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 02-22-2010, 06:37 PM   #15 (permalink)
mebarron
Registered Member
 
mebarron's Avatar
 
Join Date: Apr 2009
Location: Michigan
Posts: 47
Default

Quote:
Originally Posted by emansfield View Post
Hi,

I have a UIViewController object which is being presented as a modal view, but I am unable to set the view title. I want the title to vary depending on the context. I have tried the following:

- (void) viewWillAppearBOOL)animated {
self.title = (category ? category.name : @"Add New Category");
}

I have also tried:

- (void) viewWillAppearBOOL)animated {
self.navigationController.title = (category ? category.name : @"Add New Category");
}

neither of the above display any title.

If I set a constant title in the NIB file entry for the view controller in Interface Builder then it displays the title, but I need to be able to set it programmatically.

I can set the title for a view using the first example above on a view controller that is pushed onto the navigation controller's stack and that displays correctly, but it won't do it when presenting the view as a modal view.

Can anyone tell me what I need to do, please.
---
The discussion on this thread shows me there are other, simpler
approaches to the problem of setTitle for a NavBar. Still I send on
these thoughts.
I was unable to dynamically change the title of a ModalView.
It would take a bit of work to rework the NIBs, and switch to pushing a Modeless one.
(Plus I believe you should/can not push a modeless one from a modal one)
I made a copy of the NIB file for the ModalView I had, AddPhotoView.XIB
and changed only the Title in the navigationItem, giving two
versions of a view (AddPhotoView.XIB and EditPhotoView.XIB),
both of which using the same controller Class.
This allowed me to dynamically decide which Title to display
, using virtually identical NIBs.

There are to instance variables for the same Class:

AddPhotoViewController* addPhotoViewController; // Title: ADD PHOTO
AddPhotoViewController* editPhotoViewController; // Title: EDIT PHOTO

This seems "heavy handed" to me, but works.

- (AddPhotoViewController *)addPhotoViewController{
// only Title varies between ePVC and aPVC
if(addPhotoViewController == nil){
addPhotoViewController = [[AddPhotoViewController alloc] initWithNibName:@"AddPhotoView" bundle:nil];
}
return addPhotoViewController;
}

- (AddPhotoViewController *)editPhotoViewController{
// only Title varies between ePVC and aPVC
if(editPhotoViewController == nil){
editPhotoViewController = [[AddPhotoViewController alloc] initWithNibName:@"EditPhotoView" bundle:nil];
}
return editPhotoViewController;
}
mebarron is offline   Reply With Quote
 

» Advertisements
» Online Users: 299
16 members and 283 guests
ADY, antonwilliams, dacapo, dcool, HemiMG, iosdevjtp, jakerocheleau, leahov, MarkC, masc2279, morands, MozyMac, sly24, smithdale87, thh022, vogueestylee
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,877
Threads: 89,222
Posts: 380,720
Top Poster: BrianSlick (7,129)
Welcome to our newest member, peterkessler45
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:14 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.