2010-11-18 18 views
3

Bir RSS beslemesinden tablo görünümümde görüntüleri eşzamanlı olarak yüklemek için LazyTableImages örnek kodunu kullanıyorum. Bilmek istediğim, bu örneğe özgü yeni bir öğe eklendikten sonra bu tabloda yeniden nasıl yükleneceğini (ayrıştırma işlemini yeniden başlatmayı) olduğunu söyleyebilirim?iPhone için Örnek iPhone Örnek Kodu Yeniden Yükle Soru

http://developer.apple.com/library/ios/#samplecode/LazyTableImages/Introduction/Intro.html

çok teşekkürler.

cevap

1

Yeniden indirme isteğinde bulunmanız gerektiğini düşünüyorum. o ilk indir yapar sınıf beri Muhtemelen bunu yapar LazyTableAppDelegate için yeni bir yöntem eklemek isteyeceksiniz: Ayrıca

- (void)reloadAppList 
{ 
    NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:TopPaidAppsFeed]]; 
    self.appListFeedConnection = [[[NSURLConnection alloc] initWithRequest:urlRequest delegate:self] autorelease]; 
} 

, modifiye - [LazyTableAppDelegate handleLoadedApps:] Bu gibi eski verileri temizlemek için :

- (void)handleLoadedApps:(NSArray *)loadedApps 
{ 
    [self.appRecords removeAllObjects]; 
    rootViewController.entries = [NSArray array]; 
    [self.appRecords addObjectsFromArray:loadedApps]; 

    // tell our table view to reload its data, now that parsing has completed 
    [rootViewController.tableView reloadData]; 
} 

Bunu kendim denemedim, ama bu temel fikir.

+0

Merhaba Ryan, cevap için teşekkürler. Bunu denedim ve bunun ana fikir olduğunu anlıyorum ama çöker, ayrıca nesneleri temizlemek için handleLoadedApps değiştirerek RSS beslemesinin başlangıçta yüklenmesini engeller. Daha fazla rehberlik çok takdir edilecektir. – Hanson

+0

rootViewController.entries = [NSArray dizisi]; '' '' [rootViewController.imageDownloadsInProgress removeAllObjects] 'in değiştirilmesi; 'handleLoadedApps' içinde benim için çalışıyor gibi görünüyor. Benim durumumda 'ApplicationWillEnterForeground' içinde yeni bir' NSURLConnection 'oluşturuyorum – MrDatabase

1

Burada aynı sorunu yaşıyorum

(... Yorum yapmak bir yol bulamaz) ve bu yaklaşımı denedik. RemoveAllObjects kullanarak appRecords temizlendi, ancak ikinci kez, tüm makaleler için çalışır, ancak simgeler yüklenmez.

Orijinal numune kodu bu şekilde değiştirerek sorunu yeniden:

- (void)applicationDidFinishLaunching:(UIApplication *)application 

{ // Yapılandır ve pencere göstermek [pencere addSubview: [self.navigationController görünüm]]; [window makeKeyAndVisible];

// Initialize the array of app records and pass a reference to that list to our root view controller 
self.appRecords = [NSMutableArray array]; 
rootViewController.entries = self.appRecords; 

// NSURLRequest * urlRequest = [NSURLRequest requestWithURL: [NSURL URLWithString: TopPaidAppsFeed]]; //self.appListFeedConnection = [[[NSURLConnection ayırma] initWithRequest: urlRequest delege: self] autorelease];

// Test the validity of the connection object. The most likely reason for the connection object 
// to be nil is a malformed URL, which is a programmatic error easily detected during development 
// If the URL is more dynamic, then you should implement a more flexible validation technique, and 
// be able to both recover from errors and communicate problems to the user in an unobtrusive manner. 
// 
//NSAssert(self.appListFeedConnection != nil, @"Failure to create URL connection."); 

// show in the status bar that network activity is starting 
// [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; 
[self reloadData]; 

}

  • (IBAction) yeniden: (id) sevk { [kendini reloadData]; }

- (void) reloadData { NSLog (@ "girişleri güncellenmesi"); [self.appRecords removeAllObjects]; // [[myTableViewController imageDownloadsInProgress] removeAllObjects];

NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:TopPaidAppsFeed]]; 
self.appListFeedConnection = [[[NSURLConnection alloc] initWithRequest:urlRequest delegate:self] autorelease]; 

// Test the validity of the connection object. The most likely reason for the connection object 
// to be nil is a malformed URL, which is a programmatic error easily detected during development 
// If the URL is more dynamic, then you should implement a more flexible validation technique, and 
// be able to both recover from errors and communicate problems to the user in an unobtrusive manner. 
// 
NSAssert(self.appListFeedConnection != nil, @"Failure to create URL connection."); 

// show in the status bar that network activity is starting 
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES; 

}