Browse Source

iOS navigate

dmuratshin 9 years ago
parent
commit
89742e1277
3 changed files with 16 additions and 2 deletions
  1. 2 1
      oxygine/src/core/ios/ios.h
  2. 11 1
      oxygine/src/core/ios/ios.mm
  3. 3 0
      oxygine/src/core/oxygine.cpp

+ 2 - 1
oxygine/src/core/ios/ios.h

@@ -15,4 +15,5 @@ namespace oxygine
     bool nsImageLoad(Image& mt, void* pData, int nDatalen, bool premultiplied, TextureFormat format);
 
     void iosGetMemoryUsage(size_t& a);
-}
+    void iosNavigate(const char*);
+}

+ 11 - 1
oxygine/src/core/ios/ios.mm

@@ -2,10 +2,12 @@
 
 #if TARGET_OS_IPHONE
 #import <UIKit/UIImage.h>
+#import <UIKit/UIApplication.h>
 #else
 #import <AppKit/AppKit.h>
 #endif
 
+
 #include "ios.h"
 #include "Image.h"
 
@@ -152,4 +154,12 @@ namespace oxygine
             a = 0;
         }
     }
-}
+    
+    void iosNavigate(const char *url_)
+    {
+#if TARGET_OS_IPHONE
+        NSURL *url = [NSURL URLWithString: [NSString stringWithUTF8String:url_]];
+        [[UIApplication sharedApplication] openURL:url];
+#endif
+    }
+}

+ 3 - 0
oxygine/src/core/oxygine.cpp

@@ -51,6 +51,7 @@
 #include "core/android/jniUtils.h"
 #elif __APPLE__
 #include <TargetConditionals.h>
+#include "ios/ios.h"
 #endif
 
 #ifdef OXYGINE_SDL
@@ -854,6 +855,8 @@ namespace oxygine
                 var url = Pointer_stringify($0);
                 window.open(url, '_blank');
             }, str);
+#elif __APPLE__
+            iosNavigate(str);
 #else
             OX_ASSERT(!"execute not implemented");
 #endif