我正在创建一个应用程序,我将我的注册用户可视化到Parse.com的数据管理器(在TableView控制器中),并将所选单元的步骤数据转换为新的视图控制器。
我的问题是我无法在新的视图控制器中查看图像,你可以告诉我该怎么办?我试图在各种论坛上理解和调查argormento,但在论坛上找不到答案,而且Parse已经很长时间了,因为我没有回答。
这是我正在处理的代码:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{ if ([segue.identifier isEqualToString:@"Visual"]){
NSIndexPath *indexPath = [self.Tork indexPathForSelectedRow];
PFObject *object = [self.objects objectAtIndex:indexPath.row];
ViewController *detailViewController = [segue destinationViewController];
detailViewController.oggetto = object; } }
TableView:
- (PFQuery *)queryForTable {
PFQuery *query = [PFQuery queryWithClassName:@"_User"];
[query whereKeyExists:@"username"];
[query whereKeyExists:@"picture"];
[query whereKeyExists:@"email"];
// If no objects are loaded in memory, we look to the cache first to fill the table
// and then subsequently do a query against the network.
if ([self.objects count] == 0) {
query.cachePolicy = kPFCachePolicyCacheThenNetwork; }
[query orderByAscending:@"username"];
return query; }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
// Configure the cell
cell.textLabel.text = [object objectForKey:@"username"];
cell.detailTextLabel.text = [object objectForKey:@"email"]];
cell.imageView.image = [UIImage imageNamed:@"none.png"];
PFFile *file = [object objectForKey:@"picture"];
[file getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
cell.imageView.image =[UIImage imageWithData:data];
}];
return cell;
}
答案 0 :(得分:0)
感谢您的回复:) ...问题似乎已经解决了..我改变了以下内容为此做准备,它现在正常运作!你怎么看?你觉得合适吗?直到现在还没有导致我的应用程序崩溃。
PfQueryTableViewController.m
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"Visual"]){
NSIndexPath *indexPath = [self.tavola indexPathForSelectedRow];
PFObject *object = [self.objects objectAtIndex:indexPath.row];
PFFile *file = [self.objects objectAtIndex:indexPath.row ];
ViewController *detailViewController = [segue destinationViewController];
detailViewController.oggetto = object;
detailViewController.file = file;
}
}
DetailViewcontroller.m
- (void)viewDidLoad
{
[super viewDidLoad];
self.nome.text = [oggetto objectForKey:@"username"];
self.email.text = [oggetto objectForKey:@"email"];
PFFile *imageFile = [oggetto objectForKey:@"foto"];
[imageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
self.image.image =[UIImage imageWithData:data];
}];
}
现在我遇到了这段代码的麻烦,我在显示器上添加了一个搜索栏。代码不返回任何错误,但在开始搜索时没有显示任何结果。这是代码,你有想法吗?
- (void)callbackLoadObjectsFromParse:(NSArray *)result error:(NSError *)error {
if (!error) {
NSLog(@"Successfully fetched %d entries", result.count);
[self.searchResults addObjectsFromArray: result];
} else {
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}
- (void)filterResults:(NSString *)searchTerm {
[self.searchResults removeAllObjects];
PFQuery *query = [PFQuery queryWithClassName: @"_User"];
[query whereKeyExists:@"username"]; //this is based on whatever query you are trying to accomplish
[query whereKeyExists:@"foto"]; //this is based on whatever query you are trying to accomplish
[query whereKeyExists:@"email"];
query.cachePolicy = kPFCachePolicyNetworkOnly;
query.limit = 50;
[query findObjectsInBackgroundWithTarget:self selector:@selector(callbackLoadObjectsFromParse:error:)];
}
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString: (NSString *)searchString {
[self filterResults:searchString];
return YES;
}
日志告诉我这个,但我没有在设备上显示结果:(
AssertMacros:queueEntry,file:/ SourceCache / IOKitUser / IOKitUser-920.1.11 / hid.subproj / IOHIDEventQueue.c,line:512 09/13/2013 01:34:50.537 Unipot v.02 [412:60 b]成功获取9个条目