Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8431755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:56:28+00:00 2026-06-10T05:56:28+00:00

The app I’m working on allows the user both to read text and to

  • 0

The app I’m working on allows the user both to read text and to compose text, using different buttons. My problem now is that on the screen for reading text, if the user taps inside the UITextView box used on the screen for writing text, the keyboard appears. The UITextView in this case is self.textView; I’ve put the keyboard notifications and the keyboardWillShow method inside if(self.textView) statements and then made sure to call [self.textView removeFromSuperView] and set self.textView = nil; at the beginning of the reading text methods, but the keyboard still appears when you tap the space where self.textView is set (programmatically, by the way, not using the IB).

What am I doing wrong?

Edit: Thanks for the answers, guys and gals, but still that darn keyboard keeps coming back, just like the cat in the song…. Here’s my code. Forgive its length, please, if you can; if I’ve done something wonky I don’t know where it is, and so I don’t know what to leave out.

Here’s viewDidLoad.

-(void)viewDidLoad {
[super viewDidLoad];
self.textView.editable=NO;
self.textView.userInteractionEnabled = NO;
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(previousHaiku)];
swipeRight.numberOfTouchesRequired = 1;
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:swipeRight];
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(nextHaiku)];
swipeLeft.numberOfTouchesRequired = 1;
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
[self.view addGestureRecognizer:swipeLeft];
 NSError *error;
 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
 NSString *documentsDirectory = [paths objectAtIndex:0];
 NSString *path = [documentsDirectory stringByAppendingPathComponent:@"gayHaiku.plist"];
 NSFileManager *fileManager = [NSFileManager defaultManager];
 if (![fileManager fileExistsAtPath: path])
 {
 NSString *bundle = [[NSBundle mainBundle] pathForResource:@"gayHaiku" ofType:@"plist"];
 [fileManager copyItemAtPath:bundle toPath: path error:&error];
 }
 self.gayHaiku = [[NSMutableArray alloc] initWithContentsOfFile: path];
 [self nextHaiku];
}

Here’s nextHaiku, the last method called in viewDidLoad — this is the reading method.

-(void)nextHaiku
{
[self.view.layer removeAllAnimations];
[self.bar removeFromSuperview];
self.textToSave=@"";
self.haiku_text.text=@"";
[self.view viewWithTag:1].hidden = NO;
[self.view viewWithTag:3].hidden = NO;
int indexOfHaiku;
NSMutableArray *arrayOfHaikuSeen;
NSString *cat;
if (!self.selectedCategory) cat = @"Derfner";
else cat = self.selectedCategory;
NSArray *filteredArray;
if (cat==@"all")
{
    filteredArray = self.gayHaiku;
    indexOfHaiku = self.indxAll;
    arrayOfHaikuSeen = self.theseAreDoneAll;
}
else
{
    indexOfHaiku = (cat==@"user")?self.indxU:self.indxD;
    arrayOfHaikuSeen = (cat==@"user")?self.theseAreDoneU:self.theseAreDoneD;
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"category == %@", cat];
    filteredArray = [self.gayHaiku filteredArrayUsingPredicate:predicate];
}
int array_tot = [filteredArray count];
int sortingHat;
NSString *txt;
if (array_tot > 0)
{
    if (indexOfHaiku == arrayOfHaikuSeen.count)
    {
        while (true)
        {
            sortingHat = (arc4random() % array_tot);
            if (![arrayOfHaikuSeen containsObject:[filteredArray objectAtIndex:sortingHat]]) break;
        }
        txt = [[filteredArray objectAtIndex:sortingHat] valueForKey:@"quote"];
        if (!arrayOfHaikuSeen || arrayOfHaikuSeen.count==array_tot)
        {
            arrayOfHaikuSeen = [[NSMutableArray alloc] init];
        }
        [arrayOfHaikuSeen addObject:[filteredArray objectAtIndex:sortingHat]];
        indexOfHaiku = arrayOfHaikuSeen.count;
        if (arrayOfHaikuSeen.count==filteredArray.count)
        {
            [arrayOfHaikuSeen removeAllObjects];
            indexOfHaiku=0;
        }
    }
    else 
    {
        txt = [[arrayOfHaikuSeen objectAtIndex:indexOfHaiku] valueForKey:@"quote"];
        indexOfHaiku += 1;
    }
}
//Need to test to make sure it starts over once all 110 haiku have been seen.

CGSize dimensions = CGSizeMake(320, 400);
CGSize xySize = [txt sizeWithFont:[UIFont fontWithName:@"Helvetica" size:14.0] constrainedToSize:dimensions lineBreakMode:0];
self.haiku_text = [[UITextView alloc] initWithFrame:CGRectMake((320/2)-(xySize.width/2),200,320,200)];
self.haiku_text.font = [UIFont fontWithName:@"Helvetica Neue" size:14];
self.haiku_text.backgroundColor = [UIColor clearColor];
self.haiku_text.text=txt;
CATransition *transition = [CATransition animation];
transition.duration = 0.25;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype =kCATransitionFromRight;
transition.delegate = self;
[self.view.layer addAnimation:transition forKey:nil];
[self.view addSubview:self.haiku_text];

if (cat==@"user")
{
    self.theseAreDoneU = arrayOfHaikuSeen;
    self.indxU = indexOfHaiku;
}
else if (cat==@"all")
{
    self.theseAreDoneAll = arrayOfHaikuSeen;
    self.indxAll = indexOfHaiku;
}
else 
{
    self.theseAreDoneD = arrayOfHaikuSeen;
    self.indxD = indexOfHaiku;
}
}

And here’s the writing method.

-(void)userWritesHaiku

//Set up the screen.
[self clearScreen];
self.textView = [[UITextView alloc] initWithFrame:CGRectMake(20, 60, 280, 150)];
self.textView.delegate = self;
self.textView.returnKeyType = UIReturnKeyDefault;
self.textView.keyboardType = UIKeyboardTypeDefault;
self.textView.font = [UIFont fontWithName:@"Helvetica Neue" size:14];
self.textView.scrollEnabled = YES;
self.textView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
self.textView.userInteractionEnabled = YES;
self.textView.editable=YES;
self.textView.backgroundColor = [UIColor colorWithRed:217 green:147 blue:182 alpha:.5];
[self.view addSubview: self.textView];

[self loadNavBar:@"Compose"];
[self addLeftButton:@"Instructions" callingMethod:@"haikuInstructions"];

//If you've added text before calling haikuInstructions, when you return from haikuInstructions the textView window with the different background color AND the keyboard.
[self addRightButton:@"Done" callingMethod:@"userFinishedWritingHaiku"];
self.titulus.hidesBackButton=YES;
[self seeNavBar];

//Create and add the space for user to write.
[self createSpaceToWrite];
if (self.textToSave!=@"")
{
    self.textView.text = self.textToSave;
}
[self.view addSubview:self.textView];
[self.textView becomeFirstResponder];

//Keyboard notifications.

if (self.textView)
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:56:29+00:00Added an answer on June 10, 2026 at 5:56 am

    Well, it turned out that the whole time there was a UITextView I’d created in the xib and forgotten about because it was hiding under the main view–when I decided to create the UITextView programmatically I didn’t remember to delete the other one, because I couldn’t see it, but it was there working its evil will the entire time. I finally figured this out after commenting out literally the entire code with the exception of [super viewDidLoad] and removing everything from the xib.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

App with Facebook SDK SSO was working fine in 2.2, now upgraded Samsung Galaxy
App I'm working on uses ARC. I wanted it to process large files, so
App Engine only allows you to use these formats for XMPP addresses: app-id@appspot.com anything@app-id.appspotchat.com
The app I am working on is supporting android 2.3 upwards. As the download
The app I'm working on is relatively simple but it is throwing memory warnings.
My app allows users to have custom subdomains, as in user1.domain.com. I am integrating
The app Im working on uses gps and sometimes in the onResume when the
My app is crashing using iOS5 and iOS4.3 iPhone simulators in Xcode 4.2, the
My app is slowed down by N+1 queries. I'm using the will_paginate gem with
App Store We have been developing an app for quite some time now for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.