UA-17470720-3

Jump to content


Photo
- - - - -

Buttons on navigationBar


  • Please log in to reply
12 replies to this topic

#1 CHAU LE

CHAU LE

    Sr. Member

  • STV 5.0 Pro
  • PipPipPip
  • 32 posts
Reputation: 2
Good

Posted 12 February 2012 - 11:59 PM

Hi Tarek,

I am working on an iPad app and I want the user to be able to select a team from a CoreData table. And if the team is not there, the ability to create one on the fly quickly. I use a SCPropertyTypeObjectSelection which works OK until I add the allowAddingItems.

The navigationBar of the popup displays just a single "Edit" button. The "Cancel" and "Done" buttons have disappear giving the user no way of selecting/cancelling the action.

What did I do wrong?

SCPropertyDefinition *oppPropertyDef = [matchDef propertyDefinitionWithName:@"Opposition"];
	oppPropertyDef.type = SCPropertyTypeObjectSelection;

	SCObjectSelectionAttributes *oppPropertyDefAttributes = [SCObjectSelectionAttributes 
								 attributesWithItemsEntityClassDefinition:teamDef 
								 allowMultipleSelection:NO
								 allowNoSelection:NO];
	oppPropertyDefAttributes.allowAddingItems = YES;
	oppPropertyDefAttributes.placeholderuiElement = [SCTableViewCell cellWithText:@"(No opposition selected)"];
	oppPropertyDefAttributes.addNewObjectuiElement = [SCTableViewCell cellWithText:@"Add new team"];
	oppPropertyDef.attributes = oppPropertyDefAttributes;


#2 David DelMonte

David DelMonte

    Forum Master

  • STV 4.0 Pro
  • PipPipPipPipPipPipPip
  • 527 posts
Reputation: 41
Excellent

Posted 13 February 2012 - 01:15 PM

Hi, while you wait for Tarek, this works for me:


// CLASS DEFINITION - TYPE ENTITY
	
	SCClassDefinition *typeDef = [SCClassDefinition definitionWithEntityName:@"TypeEntity" withManagedObjectContext:managedObjectContext withPropertyNames:[NSArray arrayWithObjects:@"name", nil]];
	typeDef.orderAttributeName = @"order";
	typeDef.uiElementDelegate = self;



// PROPERTY DEFINITION = TYPE
	
	SCPropertyDefinition *typePropertyDef = [mainDef propertyDefinitionWithName:@"type"];
	typePropertyDef.type = SCPropertyTypeObjectSelection;
	typePropertyDef.title = @"Types";
	SCObjectSelectionAttributes *typeAttributes = [SCObjectSelectionAttributes 
									 
									 attributesWithItemsEntityClassDefinition:typeDef 
									 allowMultipleSelection:YES allowNoSelection:YES];
	typeAttributes.allowAddingItems = YES;
	typeAttributes.allowDeletingItems = YES;
	typeAttributes.allowMovingItems = YES;
	typeAttributes.allowEditingItems = YES;
	typeAttributes.placeholderuiElement = [SCTableViewCell cellWithText:@"Add type ...."];
	typeAttributes.addNewObjectuiElement = [SCTableViewCell cellWithText:@"Add types"];
	//typePropertyDef.attributes = [SCTextFieldAttributes attributesWithPlaceholder:@"Enter Type"];
	typePropertyDef.attributes = typeAttributes;

hope this helps

David

#3 CHAU LE

CHAU LE

    Sr. Member

  • STV 5.0 Pro
  • PipPipPip
  • 32 posts
Reputation: 2
Good

Posted 13 February 2012 - 11:28 PM

Thanks David but it gave me just the Edit button.
  • dev1 likes this

#4 CHAU LE

CHAU LE

    Sr. Member

  • STV 5.0 Pro
  • PipPipPip
  • 32 posts
Reputation: 2
Good

Posted 20 February 2012 - 08:46 AM

Any advice please Tarek?

#5 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 20 February 2012 - 04:21 PM

Hi Chau,

Did you follow here our "Core Data App" sample where you could select and create a 'Category' on the fly? Does your app generate the same interface?

#6 CHAU LE

CHAU LE

    Sr. Member

  • STV 5.0 Pro
  • PipPipPip
  • 32 posts
Reputation: 2
Good

Posted 14 March 2012 - 09:32 AM

Hi Tarek,

My app is an iPad only app.

I attached the screenshots of the popup one with allowAddingItems = YES and the other with allowAddingItems = NO.

Hope you can help me.

Many thanks
[attachment=275]allowAddingItems_YES.png[/attachment]

[attachment=276]allowAddingItems_NO.png[/attachment]

#7 CHAU LE

CHAU LE

    Sr. Member

  • STV 5.0 Pro
  • PipPipPip
  • 32 posts
Reputation: 2
Good

Posted 18 March 2012 - 08:51 PM

Any idea Tarek?

#8 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 25 March 2012 - 11:04 PM

Hi Chau,

So if I correctly understand, all you need is an extra 'Close' button on the navigation bar? Is that correct?
  • Tarek likes this

#9 CHAU LE

CHAU LE

    Sr. Member

  • STV 5.0 Pro
  • PipPipPip
  • 32 posts
Reputation: 2
Good

Posted 26 March 2012 - 12:23 AM

Hi Tarek,

It would be nice to have a Done button and a Cancel button along with the Edit button.

Also, is there any way to display the Add row at the top of the list rather than at the bottom of the list?

Cheers

#10 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 26 March 2012 - 01:29 AM

Hi Chau,

You can actually add any buttons you need in the detailViewWillAppear method:
- (void)tableViewModel:(SCTableViewModel *)tableViewModel detailViewWillAppearForRowAtIndexPath:(NSIndexPath *)indexPath withDetailTableViewModel:(SCTableViewModel *)detailTableViewModel
{
  // Add your buttons here to detailTableViewModel.viewController.navigationItem
}

In your custom button selectors, you should call the detail view's dismissWithCancelValue:doneValue:, giving the appropriate values when cancel and when done is tapped.

Also, is there any way to display the Add row at the top of the list rather than at the bottom of the list?

This is only possible in our upcoming STV 3.0. If you wish, you can add an additional section to detailTableViewModel and place a single cell in it. When the cell is tapped, call the SCArrayOfObjectsSection dispachAddNewItemEvent method.

#11 CHAU LE

CHAU LE

    Sr. Member

  • STV 5.0 Pro
  • PipPipPip
  • 32 posts
Reputation: 2
Good

Posted 26 March 2012 - 02:04 AM

Tarek,

These windows are not detail views. They are popup windows generated when I tap on a SCPropertyTypeObjectSelection field on a detail view.

#12 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 26 March 2012 - 05:52 PM

Hi Chau,

So these popups are not automatically presented by STV? Would you please post some relevant code? Thanks!

#13 CHAU LE

CHAU LE

    Sr. Member

  • STV 5.0 Pro
  • PipPipPip
  • 32 posts
Reputation: 2
Good

Posted 29 March 2012 - 09:02 PM

Hi Chau,

So these popups are not automatically presented by STV? Would you please post some relevant code? Thanks!


Yes Tarek, the popups are STV's. I set

objectsSection.detailViewModalPresentationStyle = UIModalPresentationFormSheet





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users