我想以下面的方式加載圖像。但是當我在我的tableView
中調用我的loadImageFromURL:(NSURL*)inURL
函數作爲[self loadImagesFromURL:url]
時,其顯示0字節。 如何得到我的tableview
的(delta)NSData
價值?,這是宣佈爲全球...NSData返回0字節
NSURLConnection* connection;
NSMutableData* delta;
- (void)loadImageFromURL:(NSURL*)inURL {
NSURLRequest *request = [NSURLRequest requestWithURL:inURL];
NSURLConnection *conn = [NSURLConnection connectionWithRequest:request delegate:self];
if (conn) {
delta = [[NSMutableData data] retain];
}
}
- (void)connection:(NSURLConnection *)conn didReceiveData:(NSData *)data {
[delta appendData:data];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSURL *urlink=[NSURL URLWithString:[[objectsForImages objectForKey:[arrayOfCharacters objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row]];
[self loadImageFromURL:urlink];
UIImage *imageForAz=[UIImage imageWithData:delta];
cell.imageView.image=imageForAz;
}
你確定你確實從網址接收數據? – giorashc 2012-04-01 11:35:08
是啊,數據越來越...但無法訪問我的tableview函數中的數據... – 2012-04-01 12:17:38