Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,24 @@ namespace MacCatalystApp1;

[Register ("AppDelegate")]
public class AppDelegate : UIApplicationDelegate {
public override UIWindow? Window {
get;
set;
}

public override bool FinishedLaunching (UIApplication application, NSDictionary? launchOptions)
{
// create a new window instance based on the screen size
Window = new UIWindow (UIScreen.MainScreen.Bounds);

// create a UIViewController with a single UILabel
var vc = new UIViewController ();
vc.View!.AddSubview (new UILabel (Window!.Frame) {
BackgroundColor = UIColor.SystemBackground,
TextAlignment = UITextAlignment.Center,
Text = "Hello, Mac Catalyst!",
AutoresizingMask = UIViewAutoresizing.All,
});
Window.RootViewController = vc;
// Override point for customization after application launch.
return true;
}

// make the window visible
Window.MakeKeyAndVisible ();
public override UISceneConfiguration GetConfiguration (UIApplication application, UISceneSession connectingSceneSession, UISceneConnectionOptions options)
{
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
// "Default Configuration" is defined in the Info.plist's 'UISceneConfigurationName' key.
return new UISceneConfiguration ("Default Configuration", connectingSceneSession.Role);
}

return true;
public override void DidDiscardSceneSessions (UIApplication application, NSSet<UISceneSession> sceneSessions)
{
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after 'FinishedLaunching'.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,22 @@
</array>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/AppIcon.appiconset</string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>SceneDelegate</string>
</dict>
</array>
</dict>
</dict>
</dict>
</plist>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,24 @@ public class SceneDelegate : UIResponder, IUIWindowSceneDelegate {
[Export ("scene:willConnectToSession:options:")]
public void WillConnect (UIScene scene, UISceneSession session, UISceneConnectionOptions connectionOptions)
{
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see UIApplicationDelegate `GetConfiguration` instead).
// Use this method to optionally configure and attach the UIWindow 'Window' to the provided UIWindowScene 'scene'.
// Since we are not using a storyboard, the 'Window' property needs to be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see UIApplicationDelegate 'GetConfiguration' instead).
if (scene is UIWindowScene windowScene) {
Window ??= new UIWindow (windowScene);

// Create a 'UIViewController' with a single 'UILabel'
var vc = new UIViewController ();
vc.View!.AddSubview (new UILabel (Window!.Frame) {
BackgroundColor = UIColor.SystemBackground,
TextAlignment = UITextAlignment.Center,
Text = "Hello, Mac Catalyst!",
AutoresizingMask = UIViewAutoresizing.All,
});

Window.RootViewController = vc;
Window.MakeKeyAndVisible ();
}
}

[Export ("sceneDidDisconnect:")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,22 @@ Namespace MacCatalystApp1
Public Class AppDelegate
Inherits UIApplicationDelegate

Public Overrides Property Window As UIWindow

Public Overrides Function FinishedLaunching(ByVal application As UIApplication, ByVal launchOptions As NSDictionary) As Boolean
' create a new window instance based on the screen size
Window = new UIWindow(UIScreen.MainScreen.Bounds)

' create a UIViewController with a single UILabel
Dim vc = new UIViewController()
Dim label = new UILabel(Window.Frame) With {
.BackgroundColor = UIColor.SystemBackground,
.TextAlignment = UITextAlignment.Center,
.Text = "Hello, Mac Catalyst",
.AutoresizingMask = UIViewAutoresizing.All
}
vc.View.AddSubview(label)
Window.RootViewController = vc

' make the window visible
Window.MakeKeyAndVisible()

' Override point for customization after application launch.
Return True
End Function

Public Overrides Function GetConfiguration(ByVal application As UIApplication, ByVal connectingSceneSession As UISceneSession, ByVal options As UISceneConnectionOptions) As UISceneConfiguration
' Called when a new scene session is being created.
' Use this method to select a configuration to create the new scene with.
' "Default Configuration" is defined in the Info.plist's 'UISceneConfigurationName' key.
Return New UISceneConfiguration("Default Configuration", connectingSceneSession.Role)
End Function

Public Overrides Sub DidDiscardSceneSessions(ByVal application As UIApplication, ByVal sceneSessions As NSSet(Of UISceneSession))
' Called when the user discards a scene session.
' If any sessions were discarded while the application was not running, this will be called shortly after 'FinishedLaunching'.
' Use this method to release any resources that were specific to the discarded scenes, as they will not return.
End Sub
End Class
End Namespace
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,22 @@
</array>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/AppIcon.appiconset</string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>SceneDelegate</string>
</dict>
</array>
</dict>
</dict>
</dict>
</plist>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,27 @@ Namespace MacCatalystApp1
Public Overrides Property Window As UIWindow

Public Overrides Sub WillConnect(ByVal scene As UIScene, ByVal session As UISceneSession, ByVal connectionOptions As UISceneConnectionOptions)
' Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
' If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
' This delegate does not imply the connecting scene or session are new (see UIApplicationDelegate `GetConfiguration` instead).
' Use this method to optionally configure and attach the UIWindow 'Window' to the provided UIWindowScene 'scene'.
' Since we are not using a storyboard, the 'Window' property needs to be initialized and attached to the scene.
' This delegate does not imply the connecting scene or session are new (see UIApplicationDelegate 'GetConfiguration' instead).
If TypeOf scene Is UIWindowScene Then
Dim windowScene As UIWindowScene = CType(scene, UIWindowScene)
If Window Is Nothing Then
Window = New UIWindow(windowScene)
End If

' Create a 'UIViewController' with a single 'UILabel'
Dim vc As New UIViewController()
vc.View.AddSubview(New UILabel(Window.Frame) With {
.BackgroundColor = UIColor.SystemBackground,
.TextAlignment = UITextAlignment.Center,
.Text = "Hello, Mac Catalyst!",
.AutoresizingMask = UIViewAutoresizing.All
})

Window.RootViewController = vc
Window.MakeKeyAndVisible()
End If
End Sub

Public Overrides Sub DidDisconnect(ByVal scene As UIScene)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ namespace iOSTabbedApp1;
// User Interface of the application, as well as listening (and optionally responding) to application events from iOS.
public class AppDelegate : UIResponder, IUIApplicationDelegate {

[Export ("window")]
public UIWindow? Window { get; set; }

[Export ("application:didFinishLaunchingWithOptions:")]
public bool FinishedLaunching (UIApplication application, NSDictionary? launchOptions)
{
Expand Down
35 changes: 15 additions & 20 deletions dotnet/Templates/Microsoft.iOS.Templates/ios/csharp/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,24 @@ namespace iOSApp1;

[Register ("AppDelegate")]
public class AppDelegate : UIApplicationDelegate {
public override UIWindow? Window {
get;
set;
}

public override bool FinishedLaunching (UIApplication application, NSDictionary? launchOptions)
{
// create a new window instance based on the screen size
Window = new UIWindow (UIScreen.MainScreen.Bounds);

// create a UIViewController with a single UILabel
var vc = new UIViewController ();
vc.View!.AddSubview (new UILabel (Window!.Frame) {
BackgroundColor = UIColor.SystemBackground,
TextAlignment = UITextAlignment.Center,
Text = "Hello, iOS!",
AutoresizingMask = UIViewAutoresizing.All,
});
Window.RootViewController = vc;
// Override point for customization after application launch.
return true;
}

// make the window visible
Window.MakeKeyAndVisible ();
public override UISceneConfiguration GetConfiguration (UIApplication application, UISceneSession connectingSceneSession, UISceneConnectionOptions options)
{
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
// "Default Configuration" is defined in the Info.plist's 'UISceneConfigurationName' key.
return new UISceneConfiguration ("Default Configuration", connectingSceneSession.Role);
}

return true;
public override void DidDiscardSceneSessions (UIApplication application, NSSet<UISceneSession> sceneSessions)
{
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after 'FinishedLaunching'.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}
17 changes: 17 additions & 0 deletions dotnet/Templates/Microsoft.iOS.Templates/ios/csharp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,22 @@
</array>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/AppIcon.appiconset</string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>SceneDelegate</string>
</dict>
</array>
</dict>
</dict>
</dict>
</plist>
Loading
Loading