Note that there are some explanatory texts on larger screens.

plurals
  1. POEditable TextView with Second NavBar - Text appears, but too late
    primarykey
    data
    text
    <p>Editable TextView with Second NavBar - Text appears, but too late.</p> <p>The app has a single Navigation Controller. I have an iPhone App that has basically three levels.</p> <ol> <li><p>Level 1 - Table with category Names</p></li> <li><p>Level 2 - Table with list of items for selected category</p></li> <li><p>Level 3 - Tabbed View with several views, including UITextView for details of item One to these Tabbed Views with a TextView is editable.</p> <p>When the user taps in the editable TextView the KeyBoard appears. User can type in the TextView. Characters appear as they are typed.</p> <p>At the top of this Level 3 TextView there is a NavBar (present for all 3 levels with changes) with a BackButton and a "home->Level1" button on the right.</p></li> </ol> <p>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.</p> <p>When I click these Save and Cancel buttons the correct action methods are reached. 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 relevant Button setup and action methods in my <code>TabViewController.m</code> are below. I need to persist this data.</p> <p>I thought that getting a Notification from the TextView and the action handleTextChange would do the trick, but no luck. I am stuck.</p> <pre><code>......... - (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:UIBarButtonSystemItemSave target:self action:@selector(saveAction:)]; UIBarButtonItem *cancelItemButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel 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]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload