2013-07-02 3 views
1

Я пытаюсь передать изображение от одного UIViewController к другому UIViewController. но я не добился успеха. Мой код ниже.Как сфотографировать с одного взгляда на другой Просмотр

PostGameViewController *v1=[[PostGameViewController alloc]initWithNibName:@ "PostGameViewController" bundle:nil]; 
    v1.theImg = imgPicture; 
    [self.navigationController pushViewController:v1 animated:YES]; 

// в ".h"

@interface PostGameViewController : UIViewController{ 
UIImage *img; 
UIImageView *theImg; 

} 
@property(nonatomic,retain)IBOutlet UIImageView *theImg; 

@property(nonatomic,retain)UIImage *img; 

-(IBAction)clickFacebook:(id)sender; 

// в ".m"

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 
[theImg setImage:img]; 
} 
+0

Ishant Тивари попытался @sunny ответить? – Durgaprasad

+0

imgPicture действительно?. можете ли вы отправить код этого также – Vinodh

ответ

1

Здесь у меня есть переменная String в другом представлении, как вы можете использовать для изображения.

в MainView контроллер:

UserDetailsViewController *userDetailsViewController = [[UserDetailsViewController alloc] initWithNibName:@"UserDetailsViewController" bundle:nil]; 
    userDetailsViewController.ID = idUser; 
    [self.navigationController pushViewController:userDetailsViewController animated:YES]; 

в UserDetailsViewController

в файле .h

@property(nonatomic) NSString *ID; 

в .m файл (как использование ID)

NSLog(@"ID---->%@",self.ID); 

для изображения

UserDetailsViewController *userDetailsViewController = [[UserDetailsViewController alloc] initWithNibName:@"UserDetailsViewController" bundle:nil]; 
     userDetailsViewController.img = [UIImage imageNamed:@"abc.png"]; 
     [self.navigationController pushViewController:userDetailsViewController animated:YES]; 

в файле .h

@property(nonatomic) UIImage *img; 
+0

Уважаемый Dhawal, я пытаюсь передать images.plz проверить мой код. и скажите мне, в чем проблема. –

1

попробовать, как это,

PostGameViewController *v1=[[PostGameViewController alloc]initWithNibName:@ "PostGameViewController" bundle:nil]; 
     v1.theImg.image =[UIImage imageNamed:@"imagename.png"]; 
     [self.navigationController pushViewController:v1 animated:YES]; 
0

Должно быть

PostGameViewController *v1=[[PostGameViewController alloc]initWithNibName:@ "PostGameViewController" bundle:nil]; 
v1.theImg.image = imgPicture; 
[self.navigationController pushViewController:v1 animated:YES]; 
+0

, показывая waring несовместимый указатель tpyes, назначенный UIImage из UImageView –

+0

, пожалуйста, отправьте код изображения на картинке, мы получим только четкую идею. – Vinodh

+0

'UIImage * imgPictute = [UIImage imageNamed: @" background "];' – user2398911

Смежные вопросы