UA-17470720-3

Jump to content


Photo
- - - - -

Allow Image Picking When Adding an Item


  • Please log in to reply
5 replies to this topic

#1 Bryan Saltzman

Bryan Saltzman

    Experienced Member

  • STV 2.0
  • PipPipPipPip
  • 70 posts
Reputation: 0
Neutral

Posted 31 August 2010 - 09:59 AM

I am trying to use the camera or photo album to first pick an image when adding a new item.

When I use the below code I get an error because the addItem modal view controller is not finished loading yet before I attempt to press another. Is it possible to respond to a view did load delegate? I am using itemCreatedForSectionAtIndex but the modal view is not finished loading.

- (void)tableViewModel:(SCTableViewModel *) tableViewModel itemCreatedForSectionAtIndex:(NSUInteger) index item:(NSObject *) item
{
	NSLog(@"Item created");
	[self editPhoto];
	
}

- (void) editPhoto{
	
	// If iPod Touch and no Camera
	//if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
		NSLog(@"Album Time~");
		UIImagePickerController * picker = [[UIImagePickerController alloc] init];
		picker.delegate = self;
		picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
		//picker.cameraOverlayView.
		[self presentModalViewController:picker animated:YES];

}
	

Here is the error:



2010-08-31 11:24:00.401 iScoutShoes[2703:307] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempting to begin a modal transition from to while a transition is already in progress. Wait for viewDidAppear/viewDidDisappear to know the current transition has completed'

#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 31 August 2010 - 11:30 AM

Hey Bryan-

Have you had a look at the SCTableViewModelDelegate method called tableViewModel:detailViewWillAppearForSectionAtIndex:withDetailTableViewModel ? I think you can pick your image 1st in this method before the detail controller actually appears. Please tell me if this what able to help you.

#3 Bryan Saltzman

Bryan Saltzman

    Experienced Member

  • STV 2.0
  • PipPipPipPip
  • 70 posts
Reputation: 0
Neutral

Posted 31 August 2010 - 12:26 PM

Hey Tarek,

tableViewModel:detailViewWillAppearForSectionAtIndex:withDetailTableViewMode does get triggered after itemCreatedForSectionAtIndex but not before the modal view controller is finished loading. I have the same error. Any other suggestions?

Thanks

#4 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 31 August 2010 - 01:15 PM

Yes, detailViewWillAppearForSectionAtIndex gets called way before the detail view is pushed into stack or created modally. Did I miss understand your question? It seems to me now that you actually want the detail view to appear first, then you want to display your own detail view on top of that. Is this what you want?

There is also one more thing: We are now in the process of creating a cell that provides image selection functionality. Similar to SCDateCell, when you tap this cell, it loads a detail view where you'd be able to select an image via a UIImagePickerController. Would this new cell be of any benefit to you instead of creating your own detail view?

#5 Bryan Saltzman

Bryan Saltzman

    Experienced Member

  • STV 2.0
  • PipPipPipPip
  • 70 posts
Reputation: 0
Neutral

Posted 31 August 2010 - 01:31 PM

Yes, I want to display my own image picker on top the detail view when the view loads.

The image picker cell would be nice to have for editing the image, but I want to prompt the user to pick an image first.

#6 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 31 August 2010 - 01:52 PM

Ok, I think your best option here is to handle the addButton tapping yourself (do not wire it to the SCArrayOfObjectsSection via the addButtonItem property). When the user taps the add button, present your own image picker controller. Then, after they finish selecting the image, you can call [SCArrayOfObjectsSection didTapAddButtonItem] method to handle the automatic detail view generation.

Hope this helps.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users