• Das kreative Thema des Monats Oktober wird vor allem diejenigen unter Euch besonders ansprechen, denen Do-it-yourself quasi im Blut liegt. Zeigt uns Eure Improvisationskünste oder fotografiert, was andere Leute sich so im Alltag zusammengestrickt haben. --> Zum Mitmachen bitte hier klicken

Zusätzliches Fenster öffnen

Mini-Leopard

Rhode Island Greening
Registriert
20.03.08
Beiträge
476
Liebe Community!

In einer OSX Applikation möchte ich ein zusätzliches Fenster öffnen, wenn ein Button geklickt wird.
Das funktioniert folgender maßen schon ganz gut:

Ich habe für das Fenster eine extra Klasse erzeugt.
Diese wird dann so in der Hauptklasse aufgerufen (natürlich hab ich die auch importiert):
Code:
-([COLOR=#bf2e9d]IBAction[/COLOR])showAbout:([COLOR=#bf2e9d]id[/COLOR])pId
{
[COLOR=#4b8186][COLOR=#bf2e9d]   if[/COLOR][COLOR=#000000] (! [/COLOR]myAboutAppDelegate[COLOR=#000000] )
    {[/COLOR][/COLOR]
[COLOR=#4b8186]      myAboutAppDelegate [COLOR=#000000]= [[[/COLOR]AboutAppDelegate [COLOR=#3f217c]alloc[/COLOR][COLOR=#000000]] [/COLOR][COLOR=#3f217c]init[/COLOR][COLOR=#000000]];[/COLOR][/COLOR]
   }
[COLOR=#4b8186][COLOR=#000000]    [[/COLOR]myAboutAppDelegate [COLOR=#3f217c]init[/COLOR][COLOR=#000000]];[/COLOR][/COLOR]
[COLOR=#3f217c][COLOR=#000000]    [[/COLOR][COLOR=#7340a3]NSApp [/COLOR]activateIgnoringOtherApps[COLOR=#000000]:[/COLOR][COLOR=#bf2e9d]YES[/COLOR][COLOR=#000000]];[/COLOR][/COLOR]
}

In der Klasse, die aufgerufen wird steht folgendes:
Code:
[COLOR=#bf2e9d]@implementation[/COLOR] AboutAppDelegate
-([COLOR=#bf2e9d]id[/COLOR])init
{    
[COLOR=#3f217c][COLOR=#bf2e9d]   if[/COLOR][COLOR=#000000](!([/COLOR][COLOR=#bf2e9d]self[/COLOR][COLOR=#000000] = [[/COLOR][COLOR=#bf2e9d]super [/COLOR]initWithWindowNibName[COLOR=#000000]: [/COLOR][COLOR=#d62b24]@"about"[/COLOR][COLOR=#000000]]))[/COLOR][/COLOR]
   {
[COLOR=#bf2e9d]      return nil[COLOR=#000000];[/COLOR][/COLOR]
   }
[COLOR=#bf2e9d]   return self[COLOR=#000000];[/COLOR][/COLOR]
}

Wenn ich das Fenster jetzt schließe, kann ich es allerdings nicht wieder öffnen. Es passiert gar nichts.
Ich hab im Interface Inspektor die Option "Release When Closed" sowohl an, als auch aus getestet. Hilft alles nichts.


Wäre super glücklich, wenn mir damit einer von euch helfen könnte!!
Vielen lieben Danke
Liebe Grüße
…
 
Bin jetzt auf eine "lustige" Idee gekommen:
Code:
-([COLOR=#bf2e9d]IBAction[/COLOR])showAbout:([COLOR=#bf2e9d]id[/COLOR])pId
{
[COLOR=#4b8186]    myAboutAppDelegate[COLOR=#000000] = [[[/COLOR]AboutAppDelegate [COLOR=#3f217c]alloc[/COLOR][COLOR=#000000]] [/COLOR][COLOR=#3f217c]init[/COLOR][COLOR=#000000]];[/COLOR][/COLOR]
[COLOR=#4b8186][COLOR=#000000]    [[/COLOR]myAboutAppDelegate [COLOR=#3f217c]showWindow[/COLOR][COLOR=#000000]:[/COLOR][COLOR=#bf2e9d]self[/COLOR][COLOR=#000000]];[/COLOR][/COLOR]
[COLOR=#3f217c][COLOR=#000000]    [[/COLOR][COLOR=#7340a3]NSApp [/COLOR]activateIgnoringOtherApps[COLOR=#000000]:[/COLOR][COLOR=#bf2e9d]YES[/COLOR][COLOR=#000000]];[/COLOR][/COLOR]
}

Funktioniert!
Scheinbar wir myAboutAppDelegate released, wenn ich was Fenster schließe. Macht ja nichts, geht ja jetzt.

Allerdings ist das Fenster nur aktiv, wenn ich es das erste Mal öffne.
Bei zweiten Mal ist es schon wieder inaktiv.

Und, wenn ich die Menübar entferne (was ich letzten Endes machen möchte), dann wird das Fenster nicht mal beim ersten Öffnen aktiviert.
Gibt's dazu 'ne vernüftige Lösung?

Danke, Grüße
…