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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.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-04-2011, 12:08 AM   #1 (permalink)
Registered Member
 
Ogispert's Avatar
 
Join Date: May 2011
Posts: 49
Ogispert is on a distinguished road
Default TableView with TextView. How to add multiple files? (A .txt file each row)

I'm a novice in this and I'm trying to develop a little app.

This app is about a table view, with a sub view (another table view), and finally a Text View that opens a .txt file.

My problem is that I want it to display a different .txt file each row, and I only get the same file, no matter witch row I select.

Hope someone can help me.

Thank's a lot in advance.


This is the code I have:


TEXT VIEW CONTROLLER (.M)

#pragma mark - View lifecycle

- (void)viewDidLoad
{
[Article setText:[self textSelected]];
self.title = textSelected;
[super viewDidLoad];

NSString *filepath = [[NSBundle mainBundle] pathForResource:textSelected ofType:@"txt"];
if (filepath) {
NSString *myText = [NSString stringWithContentsOfFile:filepath encoding:NSUTF8StringEncoding error:NULL];
if (myText) {
Article.text = myText;
}
}
}

- (void)viewDidUnload
{
[super viewDidUnload];
self.Article = nil;
}

ANOTHER OPTION TO LOAD THE FILE WAS:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"FILE NAME" ofType:@"txt"];
if (filePath) {
NSString *myText = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
if (myText) {
Article.text = myText;
}

BUT I DON'T KNOW HOW TO POINT A DIFFERENT FILE TO EACH ROW.


THE TABLE VIEW CONTROLLER (.M) LOOKS LIKE THIS:


- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = [contenido objectAtIndex:
[indexPath row]];
return cell;
}

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

if (self.articleViewController == nil)
{
ArticleViewController *text = [[ArticleViewController alloc]
initWithNibName:@"ArticleViewController"
bundle:[NSBundle mainBundle]];

self.articleViewController = text;
[text release];
}

[self.navigationController pushViewController:
self.articleViewController animated:YES];
}
Ogispert is offline   Reply With Quote
Old 05-04-2011, 12:14 AM   #2 (permalink)
Registered Member
 
ngaikwad's Avatar
 
Join Date: Feb 2011
Location: Mobile World
Posts: 450
ngaikwad is on a distinguished road
Default

use while giving code so each cell can display all txt file or it push to file view in next xib????
ngaikwad is offline   Reply With Quote
Old 05-04-2011, 10:31 AM   #3 (permalink)
Registered Member
 
Ogispert's Avatar
 
Join Date: May 2011
Posts: 49
Ogispert is on a distinguished road
Default

Quote:
Originally Posted by ngaikwad View Post
use while giving code so each cell can display all txt file or it push to file view in next xib????
It is a table view and when you click a row it goes to a text view with a .txt file.

The problem is that every row displays the same file and I need each row to display a different file.

All file are in the bundle.

I don't know if I have to make a TextViewController (xib) for each row (file), or it is just a matter of my code.

Thank's a lot.
Ogispert is offline   Reply With Quote
Old 05-04-2011, 11:00 PM   #4 (permalink)
Registered Member
 
ngaikwad's Avatar
 
Join Date: Feb 2011
Location: Mobile World
Posts: 450
ngaikwad is on a distinguished road
Default

Quote:
Originally Posted by Ogispert View Post
It is a table view and when you click a row it goes to a text view with a .txt file.

The problem is that every row displays the same file and I need each row to display a different file.

All file are in the bundle.

I don't know if I have to make a TextViewController (xib) for each row (file), or it is just a matter of my code.

Thank's a lot.
No not require the multiple textviewcontroller.
1. what the table view contain name of file?
2.is yes then in the next view controller send that name and in the opening of file on by that
__________________
Thank & Regard
NI3(Not Impossible 3)
ngaikwad is offline   Reply With Quote
Old 05-05-2011, 12:45 AM   #5 (permalink)
Registered Member
 
Ogispert's Avatar
 
Join Date: May 2011
Posts: 49
Ogispert is on a distinguished road
Default

Quote:
Originally Posted by ngaikwad View Post
No not require the multiple textviewcontroller.
1. what the table view contain name of file?
2.is yes then in the next view controller send that name and in the opening of file on by that
Sorry, I'm not sure if I understand you:

So, this my code for each file:
Code:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"FILE NAME" ofType:@"txt"];
if (filePath) { 
NSString *myText = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil]; 
if (myText) { 
Article.text = myText; 
}
So You say that I have to send this code for each file?... That's ok, ... But how do I separate each row and file? there is de (if.. else..) code, but I'm not sure how to use it.

I'm sorry if I don't get you right. Do you speak spanish?... yo sí.

thank's a lot.
Ogispert is offline   Reply With Quote
Old 05-05-2011, 12:50 AM   #6 (permalink)
Registered Member
 
ngaikwad's Avatar
 
Join Date: Feb 2011
Location: Mobile World
Posts: 450
ngaikwad is on a distinguished road
Default

hi
i don't know Spanish.............

i want to know that in the table what data you store that data is file name or other. and about the data sending when you click on table cell there you can use the filename=[your_array objectatindex:row];
__________________
Thank & Regard
NI3(Not Impossible 3)
ngaikwad is offline   Reply With Quote
Old 05-05-2011, 12:59 AM   #7 (permalink)
Registered Member
 
Ogispert's Avatar
 
Join Date: May 2011
Posts: 49
Ogispert is on a distinguished road
Default

Quote:
Originally Posted by ngaikwad View Post
hi
i don't know Spanish.............

i want to know that in the table what data you store that data is file name or other. and about the data sending when you click on table cell there you can use the filename=[your_array objectatindex:row];
Ok, I've tried using the same data name and then a different one, then I've change from option 1 to option 2, and the only thing that changed was the .txt file, but again, is the same for all rows.

I could send you the entire file if you want.

I would be so glad.

thank's

and i'm sorry if I don't make my self clear.
Ogispert is offline   Reply With Quote
Old 05-05-2011, 01:03 AM   #8 (permalink)
Registered Member
 
ngaikwad's Avatar
 
Join Date: Feb 2011
Location: Mobile World
Posts: 450
ngaikwad is on a distinguished road
Default

paste code here [code] tag to paste code
__________________
Thank & Regard
NI3(Not Impossible 3)
ngaikwad is offline   Reply With Quote
Old 05-05-2011, 01:12 AM   #9 (permalink)
Registered Member
 
ngaikwad's Avatar
 
Join Date: Feb 2011
Location: Mobile World
Posts: 450
ngaikwad is on a distinguished road
Default

Check that your code is as same as below

1.your table contain the filenames(any file name as u created).........
tablecell1----------a.txt
tablecell1----------b.txt
2.in the class at the method
-(void)tableviewuitableview *)tableview didselectrowatindexpathnsindexpath *)indexpath{
here you may be cal the next view??
if yes then at time calling the view u can send the file name to next view by making string object in next view controller and set the name to that and onpe the file in there viewdidload and show in there view as you make(textview or any other)
}
__________________
Thank & Regard
NI3(Not Impossible 3)
ngaikwad is offline   Reply With Quote
Old 05-05-2011, 01:12 AM   #10 (permalink)
Registered Member
 
Ogispert's Avatar
 
Join Date: May 2011
Posts: 49
Ogispert is on a distinguished road
Default

Quote:
Originally Posted by ngaikwad View Post
paste code here [code] tag to paste code
OK, MY TABLE VIEW CONTROLLER (.M) IS AS FOLLOW:

Code:
#import "LeyesViewController.h"

@implementation LeyesViewController
@synthesize contenido;
@synthesize articleViewController;

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
    }
    return self;
}

- (void)dealloc {
    [contenido release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0 || indexPath.row%2 == 0) {
        UIColor *altCellColor = [UIColor colorWithWhite:0.7 alpha:0.1];
        cell.backgroundColor = altCellColor;
    }
}

#pragma mark - View lifecycle

- (void)viewDidLoad {
	[super viewDidLoad];
}

- (void)viewWillAppear:(BOOL)animated {
    if ([self.title isEqualToString:@"Declaración"]) 
        contenido = [[NSArray alloc ] 
                 initWithObjects:@"Texto Vigente", nil];
    
    if ([self.title isEqualToString:@"De las Garantías Individuales"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 1", @"Artículo 2", nil];
    
    if ([self.title isEqualToString:@"De los Mexicanos"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 30", @"Artículo 32", nil];
    
    if ([self.title isEqualToString:@"De los Extranjeros"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 33", nil];
    
    if ([self.title isEqualToString:@"De los Ciudadanos Mexicanos"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 34",  nil];
    
    if ([self.title isEqualToString:@"De la Soberanía Nacional y de la Forma de Gobierno"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 39", @"Artículo 41", nil];
    
    if ([self.title isEqualToString:@"De las Partes Integrantes de la Federación y del Territorio Nacional"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 42", @"Artículo 48", nil];
    
    if ([self.title isEqualToString:@"De la División de Poderes"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 49", nil];
    
    if ([self.title isEqualToString:@"Del Poder Legislativo"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 50", nil];
    
    if ([self.title isEqualToString:@"De la Elección e Instalación del Congreso"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 51", nil];
    
    if ([self.title isEqualToString:@"De la Iniciativa y Formación de las Leyes"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 71", @"Artículo 72", nil];
    
    if ([self.title isEqualToString:@"De las Facultades del Congreso"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 73", nil];
    
    if ([self.title isEqualToString:@"De la Comisión Permanente"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 78", nil];
    
    if ([self.title isEqualToString:@"De la Fiscalización Superior de la Federación"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 79", nil];
    
    if ([self.title isEqualToString:@"Del Poder Ejecutivo"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 80", nil];
    
    if ([self.title isEqualToString:@"Del Poder Judicial"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 94", nil];
    
    if ([self.title isEqualToString:@"De las Responsabilidades de los Servidores Públicos y Patrimonial del Estado"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 114", nil];
    
    if ([self.title isEqualToString:@"De los Estados de la Federación y del Distrito Federal"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 115", nil];
    
    if ([self.title isEqualToString:@"Del Trabajo y de la Previsión Social"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 123", nil];
    
    if ([self.title isEqualToString:@"Prevenciones Generales"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 124", nil];
    
    if ([self.title isEqualToString:@"De las Reformas de la Constitución"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 135", nil];
    
    if ([self.title isEqualToString:@"De la Inviolabilidad de la Constitución"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo 136", nil];
    
    if ([self.title isEqualToString:@"Artículos Transitorios"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"Artículo Primero", @"Artículo Segundo", nil];
    
    if ([self.title isEqualToString:@"Decretos de Reforma"]) 
        contenido = [[NSArray alloc ] 
                    initWithObjects:@"3 de septiembre de 1993", nil];
    
    [super viewWillAppear:animated];
    [self.tableView reloadData];
}

- (void)viewDidAppear:(BOOL)animated {
            [super viewDidAppear:animated];
        }
        
- (void)viewWillDisappear:(BOOL)animated {
            [contenido release];
            [super viewWillDisappear:animated];
        }

- (void)viewDidUnload {
            self.contenido = nil;
        }
        
        - (void)viewDidDisappear:(BOOL)animated
        {
            [super viewDidDisappear:animated];
        }
        
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
	return YES;
	return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
        
#pragma mark - Table view data source
        
        - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
            return 1;
        }
        - (NSInteger)tableView:(UITableView *)tableView 
    numberOfRowsInSection:(NSInteger)section {
        return [contenido count];
    }
        - (UITableViewCell *)tableView:(UITableView *)tableView 
    cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        
        static NSString *CellIdentifier = @"Cell";
        UITableViewCell *cell = [tableView 
                                 dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] 
                     initWithStyle:UITableViewCellStyleDefault
                     reuseIdentifier:CellIdentifier] autorelease];
        }
        cell.textLabel.text = [contenido objectAtIndex: 
                               [indexPath row]];
        return cell;
    }
        
        /*
         // Override to support conditional editing of the table view.
         - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
         {
         // Return NO if you do not want the specified item to be editable.
         return YES;
         }
         */
        
        /*
         // Override to support editing the table view.
         - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
         {
         if (editingStyle == UITableViewCellEditingStyleDelete) {
         // Delete the row from the data source
         [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
         }   
         else if (editingStyle == UITableViewCellEditingStyleInsert) {
         // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
         }   
         }

#pragma mark - Table view delegate
        
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        
            //---Navigate to the details view---
            if (self.articleViewController == nil)
            {        
                ArticleViewController *text = [[ArticleViewController alloc] 
                                            initWithNibName:@"ArticleViewController" 
                                            bundle:[NSBundle mainBundle]];
                
                self.articleViewController = text;
                [text release];
            }    
            
            //---set the state selected in the method of the 
            // DetailsViewController---//
            [self.navigationController pushViewController:
             self.articleViewController animated:YES];
        }
        
@end
Ogispert is offline   Reply With Quote
Old 05-05-2011, 01:13 AM   #11 (permalink)
You win again, gravity!
 
reficul's Avatar
 
Join Date: Feb 2011
Location: Alta, Norway
Age: 38
Posts: 166
reficul is on a distinguished road
Default

The problem is that your textviewcontroller loads your article in viewDidLoad and it's only called once as you use a property to keep track of it in your tableView.
__________________
If you really want something in this life you have to work for it. Now quiet, they're about to announce the lottery numbers.

Homer J Simpson
reficul is offline   Reply With Quote
Old 05-05-2011, 01:16 AM   #12 (permalink)
Registered Member
 
Ogispert's Avatar
 
Join Date: May 2011
Posts: 49
Ogispert is on a distinguished road
Default

Quote:
Originally Posted by ngaikwad View Post
paste code here [code] tag to paste code
AND MY TEXT VIEW CONTROLLER (.M) IS:

Code:
#import "ArticleViewController.h"


@implementation ArticleViewController

@synthesize Article;
@synthesize textSelected;

-(id) initWithTextSelected:(NSString *) text {
    
    self.textSelected = text;
    [Article setText:[self textSelected]];
    return self;
}

- (void)dealloc
{
    [textSelected release];
    [Article release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [Article setText:[self textSelected]];
    self.title = textSelected;
    [super viewDidLoad];
    
	NSString *filepath = [[NSBundle mainBundle] pathForResource:textSelected ofType:@"txt"];
    if (filepath) {
        NSString *myText = [NSString stringWithContentsOfFile:filepath encoding:NSUTF8StringEncoding error:NULL];  
        if (myText) {  
            Article.text = myText;  
        }  
    }
    
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
    self.Article = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
Ogispert is offline   Reply With Quote
Old 05-05-2011, 01:26 AM   #13 (permalink)
Registered Member
 
ngaikwad's Avatar
 
Join Date: Feb 2011
Location: Mobile World
Posts: 450
ngaikwad is on a distinguished road
Default

Code:
#pragma mark - Table view delegate
        
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        
            //---Navigate to the details view---
            if (self.articleViewController == nil)
            {        
                ArticleViewController *text = [[ArticleViewController alloc] 
                                            initWithNibName:@"ArticleViewController" 
                                            bundle:[NSBundle mainBundle]];
                self.articleViewController = text;
                [text release];
            }    
            
                 ///////////////////////////////
                 here u write the data as u send that file name to next as 
                [articleViewController textfilename:abc.txt];
                ///////////

            [self.navigationController pushViewController:
             self.articleViewController animated:YES];
        }

make one method in articleviewcontroller to accept filename and in the viewdidload make shure that the text file open and show all data there

so in that way when u click on the table cell there that file name send to next view controller and that file will display
__________________
Thank & Regard
NI3(Not Impossible 3)
ngaikwad is offline   Reply With Quote
Old 05-05-2011, 02:14 AM   #14 (permalink)
Registered Member
 
Ogispert's Avatar
 
Join Date: May 2011
Posts: 49
Ogispert is on a distinguished road
Default

Quote:
Originally Posted by ngaikwad View Post
Code:
#pragma mark - Table view delegate
        
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        
            //---Navigate to the details view---
            if (self.articleViewController == nil)
            {        
                ArticleViewController *text = [[ArticleViewController alloc] 
                                            initWithNibName:@"ArticleViewController" 
                                            bundle:[NSBundle mainBundle]];
                self.articleViewController = text;
                [text release];
            }    
            
                 ///////////////////////////////
                 here u write the data as u send that file name to next as 
                [articleViewController textfilename:abc.txt];
                ///////////

            [self.navigationController pushViewController:
             self.articleViewController animated:YES];
        }

make one method in articleviewcontroller to accept filename and in the viewdidload make shure that the text file open and show all data there

so in that way when u click on the table cell there that file name send to next view controller and that file will display
It didn't work just like that...

So, do I need an .xib for each .txt file... or (I'm sorry), I keep miss understanding something.

ej. [articleViewController textfilename:abc.txt]; "abc" is my file name?

sorry, I've spent a lot of time with this and I'm a little frustrated.
Ogispert is offline   Reply With Quote
Old 05-05-2011, 02:18 AM   #15 (permalink)
Registered Member
 
ngaikwad's Avatar
 
Join Date: Feb 2011
Location: Mobile World
Posts: 450
ngaikwad is on a distinguished road
Default

Quote:
Originally Posted by Ogispert View Post
It didn't work just like that...

So, do I need an .xib for each .txt file... or (I'm sorry), I keep miss understanding something.

ej. [articleViewController textfilename:abc.txt]; "abc" is my file name?

sorry, I've spent a lot of time with this and I'm a little frustrated.
No you not require an .xib file for each *.txt file.
Yes the abc is Your file name

and don't frustrated it will solve!!!!!!!!!!!!!!!!!!!
__________________
Thank & Regard
NI3(Not Impossible 3)
ngaikwad is offline   Reply With Quote
Old 05-05-2011, 03:05 AM   #16 (permalink)
Registered Member
 
Ogispert's Avatar
 
Join Date: May 2011
Posts: 49
Ogispert is on a distinguished road
Default

Quote:
Originally Posted by ngaikwad View Post
No you not require an .xib file for each *.txt file.
Yes the abc is Your file name

and don't frustrated it will solve!!!!!!!!!!!!!!!!!!!
AGAIN THANK'S A LOT FOR YOUR PATIENCE...

Quote:
make one method in articleviewcontroller to accept filename and in the viewdidload make shure that the text file open and show all data there
So sorry about this, but, Could you explain that a little more???
Ogispert is offline   Reply With Quote
Old 05-05-2011, 03:12 AM   #17 (permalink)
You win again, gravity!
 
reficul's Avatar
 
Join Date: Feb 2011
Location: Alta, Norway
Age: 38
Posts: 166
reficul is on a distinguished road
Default

Try this. Add line in didSelectRowAtIndexPath:
Code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        
            //---Navigate to the details view---
            if (self.articleViewController == nil)
            {        
                ArticleViewController *text = [[ArticleViewController alloc] 
                                            initWithNibName:@"ArticleViewController" 
                                            bundle:[NSBundle mainBundle]];
                
                self.articleViewController = text;
                [text release];
            }    
            self.articleViewController.textSelected = [contenido objectAtIndex: 
                               [indexPath row]];
            //---set the state selected in the method of the 
            // DetailsViewController---//
            [self.navigationController pushViewController:
             self.articleViewController animated:YES];
        }
}
Change viewDidLoad, add viewWillAppear in article controller:
Code:
- (void)viewDidLoad
{
    //[Article setText:[self textSelected]];
    //self.title = textSelected;
    [super viewDidLoad];
    
	/*NSString *filepath = [[NSBundle mainBundle] pathForResource:textSelected ofType:@"txt"];
    if (filepath) {
        NSString *myText = [NSString stringWithContentsOfFile:filepath encoding:NSUTF8StringEncoding error:NULL];  
        if (myText) {  
            Article.text = myText;  
        }  
    }*/
    
    // Do any additional setup after loading the view from its nib.
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    NSString *filepath = [[NSBundle mainBundle] pathForResource:textSelected ofType:@"txt"];
    if (filepath) {
        NSString *myText = [NSString stringWithContentsOfFile:filepath encoding:NSUTF8StringEncoding error:NULL];  
        if (myText) {  
            Article.text = myText;  
        }  
    }
}
__________________
If you really want something in this life you have to work for it. Now quiet, they're about to announce the lottery numbers.

Homer J Simpson
reficul is offline   Reply With Quote
Old 05-05-2011, 03:13 AM   #18 (permalink)
Registered Member
 
ngaikwad's Avatar
 
Join Date: Feb 2011
Location: Mobile World
Posts: 450
ngaikwad is on a distinguished road
Default

Quote:
Originally Posted by Ogispert View Post
AGAIN THANK'S A LOT FOR YOUR PATIENCE...



So sorry about this, but, Could you explain that a little more???
ok.....

In the articleviewcontroller make one method any name which can only store the string .
and this string is you send from table view controller xib file.

and in viewdidload you open the file and show in that xib file(if taken text area then send all file data to there)
__________________
Thank & Regard
NI3(Not Impossible 3)
ngaikwad is offline   Reply With Quote
Old 05-05-2011, 03:21 AM   #19 (permalink)
You win again, gravity!
 
reficul's Avatar
 
Join Date: Feb 2011
Location: Alta, Norway
Age: 38
Posts: 166
reficul is on a distinguished road
Default

Quote:
and in viewdidload you open the file and show in that xib file(if taken text area then send all file data to there)
Code:
if (self.articleViewController == nil)
            {        
                ArticleViewController *text = [[ArticleViewController alloc] 
                                            initWithNibName:@"ArticleViewController" 
                                            bundle:[NSBundle mainBundle]];
                
                self.articleViewController = text;
                [text release];
            }
articleViewController is set as a property. viewDidLoad will only run once (as I mentioned earlier).
__________________
If you really want something in this life you have to work for it. Now quiet, they're about to announce the lottery numbers.

Homer J Simpson
reficul is offline   Reply With Quote
Old 05-05-2011, 03:37 AM   #20 (permalink)
Registered Member
 
ngaikwad's Avatar
 
Join Date: Feb 2011
Location: Mobile World
Posts: 450
ngaikwad is on a distinguished road
Default

Quote:
Originally Posted by reficul View Post
Code:
if (self.articleViewController == nil)
            {        
                ArticleViewController *text = [[ArticleViewController alloc] 
                                            initWithNibName:@"ArticleViewController" 
                                            bundle:[NSBundle mainBundle]];
                
                self.articleViewController = text;
                [text release];
            }
articleViewController is set as a property. viewDidLoad will only run once (as I mentioned earlier).

you can use textviewdidchange use link for that loading
__________________
Thank & Regard
NI3(Not Impossible 3)
ngaikwad is offline   Reply With Quote
Old 05-05-2011, 03:40 AM   #21 (permalink)
You win again, gravity!
 
reficul's Avatar
 
Join Date: Feb 2011
Location: Alta, Norway
Age: 38
Posts: 166
reficul is on a distinguished road
Default

Quote:
you can use textviewdidchange use link for that loading
Or the loading of the text can be done in viewWillAppear.
__________________
If you really want something in this life you have to work for it. Now quiet, they're about to announce the lottery numbers.

Homer J Simpson
reficul is offline   Reply With Quote
Old 05-05-2011, 03:42 AM   #22 (permalink)
Registered Member
 
ngaikwad's Avatar
 
Join Date: Feb 2011
Location: Mobile World
Posts: 450
ngaikwad is on a distinguished road
Default

Quote:
Originally Posted by reficul View Post
Or the loading of the text can be done in viewWillAppear.
ya thats also ok but if there also some other ibooutlet then??
__________________
Thank & Regard
NI3(Not Impossible 3)
ngaikwad is offline   Reply With Quote
Old 05-05-2011, 04:08 AM   #23 (permalink)
Registered Member
 
Ogispert's Avatar
 
Join Date: May 2011
Posts: 49
Ogispert is on a distinguished road
Default

Thank's a lot you 2, I made a little mix with your advices and I think I got it...

You are the best.

I really thank you so much.
Ogispert is offline   Reply With Quote
Old 05-05-2011, 04:17 AM   #24 (permalink)
Registered Member
 
ngaikwad's Avatar
 
Join Date: Feb 2011
Location: Mobile World
Posts: 450
ngaikwad is on a distinguished road
Default

Quote:
Originally Posted by Ogispert View Post
Thank's a lot you 2, I made a little mix with your advices and I think I got it...

You are the best.

I really thank you so much.
problem solve or not
__________________
Thank & Regard
NI3(Not Impossible 3)
ngaikwad is offline   Reply With Quote
Old 05-05-2011, 10:47 AM   #25 (permalink)
Registered Member
 
Ogispert's Avatar
 
Join Date: May 2011
Posts: 49
Ogispert is on a distinguished road
Default

Quote:
Originally Posted by ngaikwad View Post
problem solve or not
Yes indeed, problem solved.

Thank's a lot.
Ogispert is offline   Reply With Quote
Reply

Bookmarks

Tags
bundle, table view, text view, txt file

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: 351
11 members and 340 guests
dansparrow, iOS.Lover, lorrettaui53, MikaelBartlett, Nobbsy, oztemel, pbart, PlutoPrime, sledzeppelin, thephotographer, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

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