Assignment4:can't get the UIImage displayed in the UIScrollView

46 views
Skip to first unread message

Amy

unread,
Feb 27, 2012, 11:11:00 AM2/27/12
to iPhone Application Development Auditors
I've encountered a problem in assignment4,here is my code
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];
if ([segue.identifier isEqualToString:@"Show Detail"])
{
UITableViewCell *newCell = [self.tableView
cellForRowAtIndexPath:indexPath];//get a new cell
NSURL * photoURL = [FlickrFetcher urlForPhoto:
[self.photoList objectAtIndex:indexPath.row]
format:FlickrPhotoFormatLarge];
NSData *imageData = [NSData dataWithContentsOfURL:photoURL];
UIImage *img = [[UIImage alloc] initWithData:imageData];
[segue.destinationViewController setImage:img];
[segue.destinationViewController
setTitle:newCell.textLabel.text];
newCell.accessoryView = nil;
}

}
in the PhotoOfPlacesTableViewController,when I press on a cell and it
segue to a UIScrollView to show image,but now the problem is that it
just black out when I segue to the ShowPhotoViewController(where the
UIScrollView embedded in),here is the result:
http://www.flickr.com/photos/77324738@N08/6789238046/
I have two outlets (image view and scrollView) and one public property
(image) in ShowPhotoViewController,in order to show the image,I
put self.imageView.image = self.image; in ViewDidLoad. still can't
work.seek help!!!!!!!!!!!!!!!!!!!!!!!!thanks a lot!!




Maximilian Tagher

unread,
Feb 27, 2012, 3:22:20 PM2/27/12
to iphone-appd...@googlegroups.com
I just finished assignment 4, and I am having the same problem when running on my device (but not the simulator). So it sounds like the problem is in the FlickrFetcher code, or else on Flickr's end. 


On Monday, February 27, 2012, 10:11:00 UTC-6 member Amy wrote:
I've encountered a problem in assignment4, here is my code
- (void) prepareForSegue ( UIStoryboardSegue *) segue sender: (id) sender
{
    NSIndexPath * indexPath = [self.tableView indexPathForCell: sender];
    if ([segue.identifier isEqualToString: @ "Show Detail"])
    {
        UITableViewCell * newCell = [self.tableView
cellForRowAtIndexPath: indexPath] ;/ / get a new cell
          NSURL * photoURL = [FlickrFetcher urlForPhoto:
[self.photoList objectAtIndex: indexPath.row]
format: FlickrPhotoFormatLarge ] ;
          NSData * imageData = [NSData dataWithContentsOfURL: photoURL]
          UIImage * img = [[UIImage alloc] initWithData: imageData]
                [segue. destinationViewController setImage: img]
                [segue. destinationViewController
setTitle: newCell.textLabel. text];
               newCell . accessoryView = nil;
       } } in the PhotoOfPlacesTableViewControll er, When I press on a cell and it segue to a UIScrollView to show image, but now the problem is That it just black out When I segue to the ShowPhotoViewController (where the embedded in UIScrollView ), here is the result: http://www.flickr.com/photos/ 77324738 @ N08/6789238046 / I have two outlets (image view and Scrollview) and they are public property (image) in ShowPhotoViewController, in order to show the image, I put self.imageView.image = self.image; in ViewDidLoad. Still can not work.seek help!!!!!!!! thanks a lot!















Amy

unread,
Feb 27, 2012, 7:58:17 PM2/27/12
to iPhone Application Development Auditors
your program works fine on simulator??Mine just black out when segue
to imageVC, FlickrFetcher code should be OK,because NSLog the url
string from the program and it open the image you want


stephen

unread,
Feb 28, 2012, 4:24:33 PM2/28/12
to iPhone Application Development Auditors
I think I am having the same problem except I get black on both the
simulator and on my devices so I have no idea if things are working
correctly or not :-/


http://groups.google.com/group/iphone-appdev-auditors/browse_thread/thread/e330254b8072ec59

Amy

unread,
Mar 1, 2012, 8:59:04 AM3/1/12
to iPhone Application Development Auditors
er...I've figure that out,put self.imageView.image = image in
viewWillAppear,I firstly put it in viewDidLoad,you can get more
reference from teacher's next demo,photomania.
> http://groups.google.com/group/iphone-appdev-auditors/browse_thread/t...

stephen

unread,
Mar 1, 2012, 10:25:42 AM3/1/12
to iPhone Application Development Auditors
(pasting this here also for future folks)

Found the error...

The default UIViewController template was inserting a:
- (void)loadView {
// If you create your views manually, you MUST override this
method and use it to create your views.
// If you use Interface Builder to create your views, then you
must NOT override this method.
}

block that was causing the trouble. Since it was not default commented
out, it was overriding and messing up the flow. :-/

Removed that block and it works just great now.
Reply all
Reply to author
Forward
0 new messages