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

  • Home
  • SEARCH
  • 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 766031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:58:49+00:00 2026-05-14T16:58:49+00:00

I have an existing iphone project with a UITabBar. Now I need styled text

  • 0

I have an existing iphone project with a UITabBar. Now I need styled text and in-text links to other ViewControllers in my app. I am trying to integrate TTStyledTextLabel.

I have a FirstViewController:UITabelViewController with this tableView:didSelectRowAtIndexPath:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {   
    NSString *url;
    if ([self.filteredQuestions count]>0) {
        url = [NSString stringWithFormat:@"%@%d", @"tt://question/", [[self.filteredQuestions objectAtIndex:indexPath.row] id]];

        [[TTNavigator navigator] openURLAction:[[TTURLAction actionWithURLPath: url] applyAnimated:YES]];
    } else {
        Question * q = [self.questions objectAtIndex:indexPath.row] ;
        url = [NSString stringWithFormat:@"%@%d", @"tt://question/", [q.id intValue]];
    }

    TTDPRINT(@"%@", url);
    TTNavigator *navigator = [TTNavigator navigator];
    [navigator openURLAction:[[TTURLAction actionWithURLPath: url] applyAnimated:YES]];

}

My mapping looks like this:

TTNavigator* navigator = [TTNavigator navigator];
navigator.window = window;
navigator.supportsShakeToReload = YES;
TTURLMap* map = navigator.URLMap;
[map from:@"*" toViewController:[TTWebController class]];
[map from:@"tt://question/(initWithQID:)" toViewController:[QuestionDetailViewController class]];

and my QuestionDetailViewController:

@interface QuestionDetailViewController : UIViewController <UIScrollViewDelegate , QuestionDetailViewProtocol> {
    Question *question;

}

@property(nonatomic,retain) Question *question;

-(id) initWithQID:(NSString *)qid;
-(void) goBack:(id)sender;

@end

When I hit a cell, q QuestionDetailViewController will be called — but the navigationBar wont

@implementation QuestionDetailViewController
@synthesize question;


-(id) initWithQID:(NSString *)qid
{
    if (self = [super initWithNibName:@"QuestionDetailViewController" bundle:nil]) {
    //;
    TTDPRINT(@"%@", qid);

    NSManagedObjectContext *managedObjectContext = [(domainAppDelegate*)[[UIApplication sharedApplication] delegate] managedObjectContext];

    NSPredicate *predicate =[NSPredicate predicateWithFormat:@"id == %@", qid];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Question" 
                                              inManagedObjectContext:managedObjectContext];

    NSFetchRequest *request = [[NSFetchRequest alloc] init];
    [request setEntity:entity];
    [request setPredicate:predicate];
    NSError *error = nil;
    NSArray *array = [managedObjectContext executeFetchRequest:request error:&error];

    if (error==nil && [array count]>0 ) {
        self.question = [array objectAtIndex:0];
       } else {
           TTDPRINT(@"error: %@", array);
       }
    }
    return self;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    [TTStyleSheet setGlobalStyleSheet:[[[TextTestStyleSheet alloc] init] autorelease]];

    [self.navigationController.navigationBar setTranslucent:YES];
    NSArray *includedLinks = [self.question.answer.text vs_extractExternalLinks];

    NSMutableDictionary *linksToTT = [[NSMutableDictionary alloc] init];
    for (NSArray *a in includedLinks) {
        NSString *s = [a objectAtIndex:3];
        if ([s hasPrefix:@"/answer/"] || [s hasPrefix:@"http://domain.com/answer/"] || [s hasPrefix:@"http://www.domain.com/answer/"]) {
            NSString *ttAdress = @"tt://question/";
            NSArray *adressComps = [s pathComponents];
            for (NSString *s in adressComps) {
                if ([s isEqualToString:@"qid"]) {
                    ttAdress = [ttAdress stringByAppendingString:[adressComps objectAtIndex:[adressComps indexOfObject:s]+1]];
                }
            }
            [linksToTT setObject:ttAdress forKey:s];
        }
    }
    for (NSString *k in [linksToTT allKeys]) {
        self.question.answer.text = [self.question.answer.text stringByReplacingOccurrencesOfString:k withString: [linksToTT objectForKey:k]];
    }

    TTStyledTextLabel *answerText = [[[TTStyledTextLabel alloc] initWithFrame:CGRectMake(0, 0, 320, 700)] autorelease]; 
    if (![[self.question.answer.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] hasPrefix:@"<div"]) {
        self.question.answer.text = [NSString stringWithFormat:@"%<div>%@</div>", self.question.answer.text];
    }

    NSString * s = [NSString stringWithFormat:@"<div class=\"header\">%@</div>\n%@",self.question.title ,self.question.answer.text];

    answerText.text = [TTStyledText textFromXHTML:s lineBreaks:YES URLs:YES];
    answerText.contentInset = UIEdgeInsetsMake(20, 15, 20, 15);
    [answerText sizeToFit];

    [self.navigationController setNavigationBarHidden:NO animated:YES];
    [self.view addSubview:answerText];
    [(UIScrollView *)self.view setContentSize:answerText.frame.size];
    self.view.backgroundColor = [UIColor whiteColor];
    [linksToTT release];
}


.......

@end

This works quite nice, as soon as a cell is touched, a QuestionDetailViewController is called and pushed — but the tabBar will disappear, and the navigationItem — I set it like this: self.navigationItem.title =@"back to first screen"; — won’t be shown. And it just appears without animation.

But if I press a link inside the TTStyledTextLabel the animation works, the navigationItem will be shown.

How can I make the animation, the navigationItem and the tabBar be shown?

  • 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-05-14T16:58:49+00:00Added an answer on May 14, 2026 at 4:58 pm

    I found a solution:

    My QuestionDetailViewController implements the TTNavigatorDelegate.

    -(BOOL)navigator:(TTNavigator *)navigator shouldOpenURL:(NSURL *)URL will always return NO, but will call [self.navigationController pushViewController:c animated:YES];

    -(BOOL)navigator:(TTNavigator *)navigator shouldOpenURL:(NSURL *)URL {
        NSEntityDescription *entity;
        NSPredicate *predicate;
        NSFetchRequest *request = [[NSFetchRequest alloc] init];
        if ([[URL host] isEqualToString:@"question"]) {
            entity =[NSEntityDescription entityForName:@"Question" inManagedObjectContext:managedObjectContext];
            predicate = [NSPredicate predicateWithFormat:@"id == %@", [[URL path] stringByReplacingOccurrencesOfString:@"/" withString:@""]];
    
            [request setEntity:entity];
            [request setPredicate:predicate];
    
            NSError *error =nil;
            NSArray *array = [managedObjectContext executeFetchRequest:request error:&error];
            if (error==nil && [array count] >0) {
                QuestionDetailViewController *c = [[[QuestionDetailViewController alloc] init] autorelease];
                c.question = [array objectAtIndex:0];
                [self.navigationController pushViewController:c animated:YES];
            } 
        } 
        [request release];
        return NO;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an existing iPhone project that has been tested, submitted, and approved, compiled
I have an iPhone app that is a client for an existing server application.
I have an existing C++ project on a linux environment, and would like to
I have an existing web app that allows users to rate items based on
How can I set up Hessian Kit on existing iPhone project? What are the
I'd like to add core data to an existing iPhone project, but I still
In a previous project, I built an iPhone app for 2.2.x that used SQLite.
I have an existing iPhone View Controller with a corresponding view (via nib) that
in an Iphone app, I am in need of building a page that scroll
For whatever reason, I have a lot of clients that have existing data that's

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.