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 > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-25-2009, 09:48 PM   #1 (permalink)
Registered Member
 
mebarron's Avatar
 
Join Date: Apr 2009
Location: Michigan
Posts: 47
Default Editable TextView with Second NavBar - Text appears, but too late.

The app has a single Navigation Controller.
I have an iPhone App that has three levels.
Level 1 - Table with category Names
Level 2 - Table with list of items for selected category
Level 3 - Tabbed View with several views, including UITextView
One to these Tabbed Views with a TextView and is editable.
When the user taps in the editable TextView the KeyBoard
appears. User can type in the TextView. Character appear
as they are typed.

At the top of this Level 3 TextView there is a NavBar with
a BackButton and a "home->Level1" button on the right.

All works just fine until in the editable TextView I add a second NavigationBar
below the existing NavBar. This second NavBar has two buttons
as well. They are Save/Cancel left/right

When I click these Save and Cancel buttons the correct action
methods are reach. All is perfect with one exception, The text
which is typed does not appear in the TextView until either
the Save or the Cancel button is touched. The relevent Button setup and
action methods in my TabViewController.m are below.

I thought that getting a Notification from the TextView and the action handleTextChange: would
do the trick, but no luck. I am stuck. Please advise.
A noobie badly stuck and out of ideas.
Many Thanks for your time.

Mark

.........
- (void)loadView {
self.myTextView = [[UITextView alloc] init];
self.myTextView.delegate = self;

self.view = self.myTextView;
//UITextViewTextDidChangeNotification
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self
selector:@selector(handleTextChange:)
name:UITextViewTextDidChangeNotification
object:nil];
NSLog(@"Registered DG_HandleChangeTextNotification with notification center.");

}

- (void)handleTextChange:(NSNotification * )note
{

[self.myTextView setNeedsDisplay] ;
NSLog(@"...Handled Text Change.");
}


- (void)textViewDidBeginEditing:(UITextView *)textView
{
// provide my own Done/Save button to dismiss the keyboard

saveNavigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
saveNavigationBar.barStyle = UIBarStyleBlackOpaque;
UINavigationItem *doneItem = [[UINavigationItem alloc] init];
doneItem.title = @"My Notes";

UIBarButtonItem *doneItemButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemS ave target:self action:@selector(saveAction:)];
UIBarButtonItem *cancelItemButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemC ancel target:self action:@selector(cancelAction:)];

[doneItem setRightBarButtonItem:doneItemButton animated:NO];
[doneItem setLeftBarButtonItem:cancelItemButton animated:NO];
[saveNavigationBar pushNavigationItem:doneItem animated:NO];

[self.view addSubview:saveNavigationBar];

[doneItem release];
[cancelItemButton release];
[doneItemButton release];
}

- (void)saveAction:(id)sender
{
// finish typing text/dismiss the keyboard by removing it as the first responder
//
self.text = self.myTextView.text;
[self.saveNavigationBar removeFromSuperview];
[self.myTextView resignFirstResponder];

}

- (void)cancelAction:(id)sender
{
[self.saveNavigationBar removeFromSuperview];
[self.myTextView resignFirstResponder];

}
mebarron is offline   Reply With Quote
Reply

Bookmarks

Tags
navigationbarbutton, uitabbarcontroller, uitextview

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: 280
20 members and 260 guests
ADY, Bertrand21, Dani77, HemiMG, iDifferent, IphoneSdk, jakerocheleau, JasonR, jimbo, macquitzon216, MACralik, mer10, NSeven, prchn4christ, Rudy, silverwiz, spiderguy84, Sunny46
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,767
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

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