привет, я разрабатываю iOS, который показывает обновления изображений. Для использования NSURLConnectionDelegate
и setDatasource
, чтобы довести изображение до tableview
с помощью php
и json
сейчас я пытаюсь предоставить параметр подробного просмотра для моего табличного представления, так как в это время может возникнуть трудное время, пожалуйста, помогите мне.Как просмотреть изображение в подробном виде контроллера в виде таблицы?
setdatasource
кодирования imagecell.m
-(void)setDataSource:(image *)inImageObj
{
self.decriptionLabel.text = inImageObj.desp;
NSURL *url = [NSURL URLWithString:inImageObj.img];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
self.responseData = [[NSMutableData alloc] init];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;
{
[self.responseData appendData:data];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection;
{
UIImage *image = [UIImage imageWithData:self.responseData];
self.thumbImageView.image = image;
}
это код, который я использовал для просмотра изображений в таблице view.m
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *cellIdentifier [email protected]"Cell";
imgpoliticalCell *cell =(imgpoliticalCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell== nil) {
cell = [[imgpoliticalCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
[cell setDataSource:[imgevery objectAtIndex:indexPath.row]];
return cell;
}
теперь я хочу просмотреть изображение и описание в detailviewcontroller
. Я попытался с Segue я не смог получить его правильно
detailviewcontroller.h файл
@interface DetailpoliticalViewController : UIViewController
@property (strong,nonatomic) UIImage * image;
@property (strong,nonatomic) NSString * data;
@property (strong, nonatomic) IBOutlet UIImageView *imageview;
@property (strong, nonatomic) IBOutlet UILabel *view;
это код, который я использовал в detailviewcontroller.m файл
@implementation DetailpoliticalViewController
@synthesize imageview,view;
@synthesize image,data;
- (void)viewDidLoad
{
[super viewDidLoad];
self.imageview.image = self.image;
self.view.text= self.data;
// Do any additional setup after loading the view.
}
И это код push-segue, который я использовал в контроллере табличного представления
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"Detailsegue"]) {
DetailpoliticalViewController *detailvc =(DetailpoliticalViewController *)segue.destinationViewController;
NSIndexPath *indexPath =[self.mytableview indexPathForCell:(UITableViewCell *) sender];
image * eve = [imgevery objectAtIndex:indexPath.row];
[detailvc setDataSource:[imgevery objectAtIndex:indexPath.row]];
}
Теперь я не могу просмотреть изображение и описание на мой взгляд, детали контроллера я получаю ноль ошибку исключения
пожалуйста, может ли один предложить какой-нибудь способ, чтобы просмотреть детали
благодарите заранее