Hi Tarek
Thanks - dont worry about the typo - you have only made one mistake in the history of STV - you should see how many I have made
I added in the code and it now runs - the settings button shows, but the app terminates.
I changed the code to:
// Create the toolbar that will hold the Add and Edit buttons
UIToolbar* toolbar = [UIToolbar alloc]
initWithFrame:CGRectMake(0, 0, 100, 44.01)];
// Set the toolbar style to the correct style
toolbar.barStyle = self.navigationController.navigationBar.barStyle;
// create an array of the buttons
NSMutableArray* buttons = [NSMutableArray alloc] initWithCapacity:3];
UIBarButtonItem *_addButton = [UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self
action:@selector(addButtonTapped)];
self.addButtonItem = _addButton;
[_addButton release];
[buttons addObject:self.addButtonItem];
UIBarButtonItem *spacer = [UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
target:nil action:nil];
[buttons addObject:spacer];
[spacer release];
UIBarButtonItem *showSettings = [UIBarButtonItem alloc]
initWithTitle:@"Settings" style:UIBarButtonItemStyleBordered
target:self action:@selector(showSettings)]; // Assumes you have a method called settingsButtonTapped
[buttons addObject:showSettings];
[showSettings release];
// add the buttons to the toolbar
[toolbar setItems:buttons animated:NO];
[buttons release];
// place the toolbar into the navigation bar
UIBarButtonItem *toolbarButton = [UIBarButtonItem alloc] initWithCustomView:toolbar];
self.navigationItem.rightBarButtonItem = toolbarButton;
[toolbar release];
[toolbarButton release];
I have the following method called showSettings set up:
- (IBAction)showSettings:(id)sender {
[popoverController dismissPopoverAnimated:YES];
if (!settingsPopoverController){
SettingsViewController * settings=[SettingsViewController alloc] initWithStyle:UITableViewStyleGrouped];
settingsPopoverController = [UIPopoverController alloc] initWithContentViewController:settings];
[settings release];
};
if(! settingsPopoverController.popoverVisible){
[settingsPopoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];}
else {
[settingsPopoverController dismissPopoverAnimated:YES];
}
Any ideas why it is terminating ?
Iain