0
저는 Parse.com (이미지, 하나의 제목 및 하나의 설명)에서 내용을 가져 와서 내 detailView에 UIView를 사용하고있는 tableView를 가지고 있습니다. 셀을 탭하면 UIView에 애니메이션이 제공됩니다. 내 제목과 이벤트 설명을 얻을 수 있었지만 이미지 파일을 가져올 수 없었습니다.TableView에서 UIView로 이미지 전달하기
구문 분석 된 이미지를 UIView에 전달하는 방법은 무엇입니까?
감사합니다. 여기
은 여기 내 .H 파일#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
#import "TableCell.h"
@interface ViewController : UIViewController <UITableViewDelegate> {
NSArray *events;
}
@property (weak, nonatomic) IBOutlet UITableView *newsTable;
@property (strong, nonatomic) IBOutlet UIView *detailView;
@property (strong, nonatomic) IBOutlet UILabel *InfoDetailLabel;
- (IBAction)backBtn:(id)sender;
@property (strong, nonatomic) IBOutlet UILabel *viewTitle;
인하는 .m 파일을
#import "ViewController.h"
#import "TableCell.h"
#import "Reachability.h"
@interface ViewController()
@end
@implementation ViewController
@synthesize newsTable;
- (BOOL)connected
{
Reachability *reachability = [Reachability reachabilityForInternetConnection];
NetworkStatus networkStatus = [reachability currentReachabilityStatus];
return !(networkStatus == NotReachable);
}
- (void)viewDidLoad
{
[super viewDidLoad];
//Pull to refresh
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
[self.newsTable addSubview:refreshControl];
//Checking connection
if (![self connected])
{
// not connected
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Internet Connection Not Found" message:@"Please check your network settings!" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
} else
{
// connected, do some internet stuff
}
// Do any additional setup after loading the view, typically from a nib.
[self performSelector: @selector(retreiveFromParse)];
}
//pull to refresh
- (void)refresh:(UIRefreshControl *)refreshControl {
[refreshControl endRefreshing];
}
- (void) retreiveFromParse {
PFQuery *retrieveEvents = [PFQuery queryWithClassName:@"News"];
[retrieveEvents findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
events = [[NSArray alloc] initWithArray:objects];
}
[newsTable reloadData];
}];
}
//*********************Setup table of folder names ************************
//get number of sections in tableview
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
//get number of rows by counting number of folders
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return events.count;
}
//setup cells in tableView
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//setup cell
static NSString *CellIdentifier = @"EventCell";
TableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
PFObject *tempObject = [events objectAtIndex:indexPath.row];
cell.TitleLabel.text = [tempObject objectForKey:@"Event"];
cell.DescriptionLabel.text = [tempObject objectForKey:@"Description"];
// To get the image file from Parse class
PFFile *imageFile = [tempObject objectForKey:@"imageFile"];
PFImageView *imageView = [[PFImageView alloc] init];
imageView.file = imageFile;
[imageView loadInBackground:^(UIImage *img,NSError *error){
if(!error)
{
UIImageView *yourImageView = [[UIImageView alloc] init];
yourImageView.image = imageView.image;
/*OR*/
cell.imageView.image = imageView.image;
}}];
return cell;
}
//user selects folder to add tag to
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"cell tapped");
//For detail view
PFObject *tempObject = [ events objectAtIndex:indexPath.row];
NSLog(@"%@", tempObject.objectId);
_InfoDetailLabel.text = [tempObject objectForKey:@"detailinformation"];
[self animateDetailView];
_viewTitle.text = [tempObject objectForKey:@"Event"];
[self animateDetailView];
}
//for animation of detailview
- (void) animateDetailView {
[UIView animateWithDuration:0.3 animations:^{
_detailView.frame = CGRectMake(0, 0, 320, 518);
}];
}
//back button with animation
- (IBAction)backBtn:(id)sender {
[UIView animateWithDuration:0.3 animations:^{
_detailView.frame = CGRectMake(320, 0, 320, 518);
}];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
내 세포 .H
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
@interface TableCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UILabel *TitleLabel;
@property (strong, nonatomic) IBOutlet UILabel *DescriptionLabel;
@property (strong, nonatomic) IBOutlet PFImageView *imageView;
@end
감사합니다. 그러나 이것은 작동하지 않았습니다. – user3499983
@ user3499983'cellForRowAtIndexPath :'에'cell.imageView.image = img;'를 설정하고 있습니까? – Akhilrajtr
그래, 그랬어. 어쩌면 내가 뭔가 잘못하고있는 것 같아. – user3499983