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 08-19-2010, 03:13 AM   #1 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 31
pete42 is on a distinguished road
Question Website Title in TableView Cell

Alright so the thing is that i want to display a website title in a tableview cell but it doesnt seem to work properly.

im using this to get it.
Code:
#pragma mark -
#pragma mark View lifecycle

- (void)viewDidLoad {
    [super viewDidLoad];
	webView1 = [[UIWebView alloc] init];

}
	
#pragma mark 
#pragma mark Table view data source

// Customize the number of sections in the table view.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}


// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 20;
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }
    
	cell.textLabel.text = [NSString stringWithFormat:@"%i", indexPath.row];
	
	NSString *number;
	if (indexPath.row < 10) {
		number = [NSString stringWithFormat:@"000%i", indexPath.row];
 	}
	
	else if (indexPath.row < 100) {
		number = [NSString stringWithFormat:@"00%i", indexPath.row];
 	}
	
	else if (indexPath.row < 1000) {
		number = [NSString stringWithFormat:@"0%i", indexPath.row];
 	}
	
	else {
		number = [NSString stringWithFormat:@"%i", indexPath.row];
 	}
	
	NSString *urls = [NSURL URLWithString:[NSString stringWithFormat:@"http://live.nhl.com/ice/realtime.htm?id=201002%@", number]];
	NSURLRequest *requestObj = [NSURLRequest requestWithURL:(NSURL *)urls];
	
	[webView1 loadRequest:requestObj];
	
	NSString *mySTR;	
	mySTR = [webView1 stringByEvaluatingJavaScriptFromString:@"document.title"];
	
	cell.detailTextLabel.text = mySTR;
	
	// Configure the cell.
	
    return cell;
but what happens is that it only displays the last title because finding the title dosent happen instantly when the page is loaded. ive tried to using loops in the viewDidLoad method to try to get each to display but without success. Ive tried everything from making the app sleep to creating multiple functions to make the titles display properly.

If anyone knows how to make this work it would be great help since it would save me loads of time.

thanks
pete42 is offline   Reply With Quote
Reply

Bookmarks

Tags
tabel, title, uiwebview, webpage, website

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: 347
5 members and 342 guests
freewind, givensur, lendo, Newbie123, PlutoPrime
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,894
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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