├── .gitignore ├── README.md ├── TVKitApp ├── NativeScript │ ├── include │ │ ├── NativeScript.h │ │ ├── TNSRuntime+Inspector.h │ │ └── TNSRuntime.h │ ├── lib │ │ ├── libJavaScriptCore.a │ │ ├── libNativeScript.a │ │ ├── libWTF.a │ │ ├── libbmalloc.a │ │ └── libffi.a │ ├── metadata.bin │ └── nativescript-build.xcconfig ├── TVKitApp.xcodeproj │ └── project.pbxproj └── TVKitApp │ ├── Info.plist │ ├── app │ └── index.js │ └── main.m └── screenshots └── UIPageViewController.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata 19 | 20 | ## Other 21 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | #Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is a **proof of concept** app with [NativeScript for iOS](https://github.com/NativeScript/ios-runtime) running on [Apple TV](http://www.apple.com/tv/). 2 | 3 | You can find more info in the related [blog post](https://www.nativescript.org/blog/running-the-nativescript-runtime-for-ios-on-apple-tv). 4 | 5 | ![UIPageViewController](screenshots/UIPageViewController.png) 6 | 7 | ## Requirements 8 | * OS X 10.10.4+ 9 | * Xcode 7.1+ 10 | 11 | ## Getting Started 12 | This is a plain Xcode project, without the NativeScript CLI. 13 | 14 | To run the application simply open the Xcode project in the `TVKitApp` folder and click "Play". 15 | -------------------------------------------------------------------------------- /TVKitApp/NativeScript/include/NativeScript.h: -------------------------------------------------------------------------------- 1 | // 2 | // NativeScript.h 3 | // NativeScript 4 | // 5 | // Created by Yavor Georgiev on 15.07.14. 6 | // Copyright (c) 2014 г. Telerik. All rights reserved. 7 | // 8 | 9 | #import "TNSRuntime.h" 10 | #import "TNSRuntime+Inspector.h" 11 | -------------------------------------------------------------------------------- /TVKitApp/NativeScript/include/TNSRuntime+Inspector.h: -------------------------------------------------------------------------------- 1 | // 2 | // TNSRuntime+Inspector.h 3 | // NativeScript 4 | // 5 | // Created by Yavor Georgiev on 01.08.14. 6 | // Copyright (c) 2014 г. Telerik. All rights reserved. 7 | // 8 | 9 | #import "TNSRuntime.h" 10 | #import 11 | 12 | FOUNDATION_EXPORT NSString* const TNSInspectorRunLoopMode; 13 | 14 | @interface TNSRuntimeInspector : NSObject 15 | 16 | + (BOOL)logsToSystemConsole; 17 | + (void)setLogsToSystemConsole:(BOOL)shouldLog; 18 | 19 | - (void)dispatchMessage:(NSString*)message; 20 | 21 | - (void)reportFatalError:(JSValueRef)error __attribute__((noreturn)); 22 | 23 | - (void)pause; 24 | 25 | @end 26 | 27 | typedef void (^TNSRuntimeInspectorMessageHandler)(NSString* message); 28 | 29 | @interface TNSRuntime (Inspector) 30 | 31 | - (TNSRuntimeInspector*)attachInspectorWithHandler:(TNSRuntimeInspectorMessageHandler)messageHandler; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /TVKitApp/NativeScript/include/TNSRuntime.h: -------------------------------------------------------------------------------- 1 | // 2 | // TNSRuntime.h 3 | // NativeScript 4 | // 5 | // Created by Yavor Georgiev on 01.08.14. 6 | // Copyright (c) 2014 г. Telerik. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | typedef void (*TNSUncaughtErrorHandler)(JSContextRef ctx, JSValueRef error); 13 | 14 | FOUNDATION_EXTERN void TNSSetUncaughtErrorHandler(TNSUncaughtErrorHandler handler); 15 | 16 | @interface TNSRuntime : NSObject 17 | 18 | @property(nonatomic, retain) NSString* applicationPath; 19 | 20 | + (void)initializeMetadata:(void*)metadataPtr; 21 | 22 | - (instancetype)initWithApplicationPath:(NSString*)applicationPath; 23 | 24 | - (JSGlobalContextRef)globalContext; 25 | 26 | - (void)executeModule:(NSString*)entryPointModuleIdentifier; 27 | 28 | @end -------------------------------------------------------------------------------- /TVKitApp/NativeScript/lib/libJavaScriptCore.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/sample-tvOS/d73ed68614a2efd82f5cb1f22d69dda9d7abc722/TVKitApp/NativeScript/lib/libJavaScriptCore.a -------------------------------------------------------------------------------- /TVKitApp/NativeScript/lib/libNativeScript.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/sample-tvOS/d73ed68614a2efd82f5cb1f22d69dda9d7abc722/TVKitApp/NativeScript/lib/libNativeScript.a -------------------------------------------------------------------------------- /TVKitApp/NativeScript/lib/libWTF.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/sample-tvOS/d73ed68614a2efd82f5cb1f22d69dda9d7abc722/TVKitApp/NativeScript/lib/libWTF.a -------------------------------------------------------------------------------- /TVKitApp/NativeScript/lib/libbmalloc.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/sample-tvOS/d73ed68614a2efd82f5cb1f22d69dda9d7abc722/TVKitApp/NativeScript/lib/libbmalloc.a -------------------------------------------------------------------------------- /TVKitApp/NativeScript/lib/libffi.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/sample-tvOS/d73ed68614a2efd82f5cb1f22d69dda9d7abc722/TVKitApp/NativeScript/lib/libffi.a -------------------------------------------------------------------------------- /TVKitApp/NativeScript/metadata.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/sample-tvOS/d73ed68614a2efd82f5cb1f22d69dda9d7abc722/TVKitApp/NativeScript/metadata.bin -------------------------------------------------------------------------------- /TVKitApp/NativeScript/nativescript-build.xcconfig: -------------------------------------------------------------------------------- 1 | HEADER_SEARCH_PATHS = $(inherited) $(SRCROOT)/NativeScript/include 2 | OTHER_LDFLAGS = $(inherited) -sectcreate __DATA __TNSMetadata $(SRCROOT)/NativeScript/metadata.bin -L$(SRCROOT)/NativeScript/lib -lNativeScript -lJavaScriptCore -lWTF -lffi -lbmalloc -licucore -lz -lc++ -framework MobileCoreServices -framework UIKit -framework CoreGraphics 3 | -------------------------------------------------------------------------------- /TVKitApp/TVKitApp.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | CDF3CA5A1BA999A0005BED2C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = CDF3CA591BA999A0005BED2C /* main.m */; }; 11 | CDF3CA951BA9A90A005BED2C /* app in Resources */ = {isa = PBXBuildFile; fileRef = CDF3CA941BA9A90A005BED2C /* app */; }; 12 | /* End PBXBuildFile section */ 13 | 14 | /* Begin PBXFileReference section */ 15 | CDF3CA551BA999A0005BED2C /* TVKitApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TVKitApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 16 | CDF3CA591BA999A0005BED2C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 17 | CDF3CA661BA999A0005BED2C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 18 | CDF3CA8D1BA9A3B6005BED2C /* nativescript-build.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = "nativescript-build.xcconfig"; path = "NativeScript/nativescript-build.xcconfig"; sourceTree = SOURCE_ROOT; }; 19 | CDF3CA941BA9A90A005BED2C /* app */ = {isa = PBXFileReference; lastKnownFileType = folder; path = app; sourceTree = ""; }; 20 | /* End PBXFileReference section */ 21 | 22 | /* Begin PBXFrameworksBuildPhase section */ 23 | CDF3CA521BA999A0005BED2C /* Frameworks */ = { 24 | isa = PBXFrameworksBuildPhase; 25 | buildActionMask = 2147483647; 26 | files = ( 27 | ); 28 | runOnlyForDeploymentPostprocessing = 0; 29 | }; 30 | /* End PBXFrameworksBuildPhase section */ 31 | 32 | /* Begin PBXGroup section */ 33 | CDF3CA4C1BA999A0005BED2C = { 34 | isa = PBXGroup; 35 | children = ( 36 | CDF3CA571BA999A0005BED2C /* TVKitApp */, 37 | CDF3CA561BA999A0005BED2C /* Products */, 38 | ); 39 | sourceTree = ""; 40 | }; 41 | CDF3CA561BA999A0005BED2C /* Products */ = { 42 | isa = PBXGroup; 43 | children = ( 44 | CDF3CA551BA999A0005BED2C /* TVKitApp.app */, 45 | ); 46 | name = Products; 47 | sourceTree = ""; 48 | }; 49 | CDF3CA571BA999A0005BED2C /* TVKitApp */ = { 50 | isa = PBXGroup; 51 | children = ( 52 | CDF3CA941BA9A90A005BED2C /* app */, 53 | CDF3CA661BA999A0005BED2C /* Info.plist */, 54 | CDF3CA581BA999A0005BED2C /* Supporting Files */, 55 | ); 56 | path = TVKitApp; 57 | sourceTree = ""; 58 | }; 59 | CDF3CA581BA999A0005BED2C /* Supporting Files */ = { 60 | isa = PBXGroup; 61 | children = ( 62 | CDF3CA8D1BA9A3B6005BED2C /* nativescript-build.xcconfig */, 63 | CDF3CA591BA999A0005BED2C /* main.m */, 64 | ); 65 | name = "Supporting Files"; 66 | sourceTree = ""; 67 | }; 68 | /* End PBXGroup section */ 69 | 70 | /* Begin PBXNativeTarget section */ 71 | CDF3CA541BA999A0005BED2C /* TVKitApp */ = { 72 | isa = PBXNativeTarget; 73 | buildConfigurationList = CDF3CA691BA999A0005BED2C /* Build configuration list for PBXNativeTarget "TVKitApp" */; 74 | buildPhases = ( 75 | CDF3CA511BA999A0005BED2C /* Sources */, 76 | CDF3CA521BA999A0005BED2C /* Frameworks */, 77 | CDF3CA531BA999A0005BED2C /* Resources */, 78 | ); 79 | buildRules = ( 80 | ); 81 | dependencies = ( 82 | ); 83 | name = TVKitApp; 84 | productName = TVKitApp; 85 | productReference = CDF3CA551BA999A0005BED2C /* TVKitApp.app */; 86 | productType = "com.apple.product-type.application"; 87 | }; 88 | /* End PBXNativeTarget section */ 89 | 90 | /* Begin PBXProject section */ 91 | CDF3CA4D1BA999A0005BED2C /* Project object */ = { 92 | isa = PBXProject; 93 | attributes = { 94 | LastUpgradeCheck = 0710; 95 | ORGANIZATIONNAME = NativeScript; 96 | TargetAttributes = { 97 | CDF3CA541BA999A0005BED2C = { 98 | CreatedOnToolsVersion = 7.1; 99 | }; 100 | }; 101 | }; 102 | buildConfigurationList = CDF3CA501BA999A0005BED2C /* Build configuration list for PBXProject "TVKitApp" */; 103 | compatibilityVersion = "Xcode 3.2"; 104 | developmentRegion = English; 105 | hasScannedForEncodings = 0; 106 | knownRegions = ( 107 | en, 108 | Base, 109 | ); 110 | mainGroup = CDF3CA4C1BA999A0005BED2C; 111 | productRefGroup = CDF3CA561BA999A0005BED2C /* Products */; 112 | projectDirPath = ""; 113 | projectRoot = ""; 114 | targets = ( 115 | CDF3CA541BA999A0005BED2C /* TVKitApp */, 116 | ); 117 | }; 118 | /* End PBXProject section */ 119 | 120 | /* Begin PBXResourcesBuildPhase section */ 121 | CDF3CA531BA999A0005BED2C /* Resources */ = { 122 | isa = PBXResourcesBuildPhase; 123 | buildActionMask = 2147483647; 124 | files = ( 125 | CDF3CA951BA9A90A005BED2C /* app in Resources */, 126 | ); 127 | runOnlyForDeploymentPostprocessing = 0; 128 | }; 129 | /* End PBXResourcesBuildPhase section */ 130 | 131 | /* Begin PBXSourcesBuildPhase section */ 132 | CDF3CA511BA999A0005BED2C /* Sources */ = { 133 | isa = PBXSourcesBuildPhase; 134 | buildActionMask = 2147483647; 135 | files = ( 136 | CDF3CA5A1BA999A0005BED2C /* main.m in Sources */, 137 | ); 138 | runOnlyForDeploymentPostprocessing = 0; 139 | }; 140 | /* End PBXSourcesBuildPhase section */ 141 | 142 | /* Begin XCBuildConfiguration section */ 143 | CDF3CA671BA999A0005BED2C /* Debug */ = { 144 | isa = XCBuildConfiguration; 145 | baseConfigurationReference = CDF3CA8D1BA9A3B6005BED2C /* nativescript-build.xcconfig */; 146 | buildSettings = { 147 | ALWAYS_SEARCH_USER_PATHS = NO; 148 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 149 | CLANG_CXX_LIBRARY = "libc++"; 150 | CLANG_ENABLE_MODULES = YES; 151 | CLANG_ENABLE_OBJC_ARC = YES; 152 | CLANG_WARN_BOOL_CONVERSION = YES; 153 | CLANG_WARN_CONSTANT_CONVERSION = YES; 154 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 155 | CLANG_WARN_EMPTY_BODY = YES; 156 | CLANG_WARN_ENUM_CONVERSION = YES; 157 | CLANG_WARN_INT_CONVERSION = YES; 158 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 159 | CLANG_WARN_UNREACHABLE_CODE = YES; 160 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 161 | COPY_PHASE_STRIP = NO; 162 | DEBUG_INFORMATION_FORMAT = dwarf; 163 | ENABLE_STRICT_OBJC_MSGSEND = YES; 164 | ENABLE_TESTABILITY = YES; 165 | GCC_C_LANGUAGE_STANDARD = gnu99; 166 | GCC_DYNAMIC_NO_PIC = NO; 167 | GCC_NO_COMMON_BLOCKS = YES; 168 | GCC_OPTIMIZATION_LEVEL = 0; 169 | GCC_PREPROCESSOR_DEFINITIONS = ( 170 | "DEBUG=1", 171 | "$(inherited)", 172 | ); 173 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 174 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 175 | GCC_WARN_UNDECLARED_SELECTOR = YES; 176 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 177 | GCC_WARN_UNUSED_FUNCTION = YES; 178 | GCC_WARN_UNUSED_VARIABLE = YES; 179 | MTL_ENABLE_DEBUG_INFO = YES; 180 | ONLY_ACTIVE_ARCH = YES; 181 | SDKROOT = appletvos; 182 | TARGETED_DEVICE_FAMILY = 3; 183 | TVOS_DEPLOYMENT_TARGET = 9.0; 184 | }; 185 | name = Debug; 186 | }; 187 | CDF3CA681BA999A0005BED2C /* Release */ = { 188 | isa = XCBuildConfiguration; 189 | baseConfigurationReference = CDF3CA8D1BA9A3B6005BED2C /* nativescript-build.xcconfig */; 190 | buildSettings = { 191 | ALWAYS_SEARCH_USER_PATHS = NO; 192 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 193 | CLANG_CXX_LIBRARY = "libc++"; 194 | CLANG_ENABLE_MODULES = YES; 195 | CLANG_ENABLE_OBJC_ARC = YES; 196 | CLANG_WARN_BOOL_CONVERSION = YES; 197 | CLANG_WARN_CONSTANT_CONVERSION = YES; 198 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 199 | CLANG_WARN_EMPTY_BODY = YES; 200 | CLANG_WARN_ENUM_CONVERSION = YES; 201 | CLANG_WARN_INT_CONVERSION = YES; 202 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 203 | CLANG_WARN_UNREACHABLE_CODE = YES; 204 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 205 | COPY_PHASE_STRIP = NO; 206 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 207 | ENABLE_NS_ASSERTIONS = NO; 208 | ENABLE_STRICT_OBJC_MSGSEND = YES; 209 | GCC_C_LANGUAGE_STANDARD = gnu99; 210 | GCC_NO_COMMON_BLOCKS = YES; 211 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 212 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 213 | GCC_WARN_UNDECLARED_SELECTOR = YES; 214 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 215 | GCC_WARN_UNUSED_FUNCTION = YES; 216 | GCC_WARN_UNUSED_VARIABLE = YES; 217 | MTL_ENABLE_DEBUG_INFO = NO; 218 | SDKROOT = appletvos; 219 | TARGETED_DEVICE_FAMILY = 3; 220 | TVOS_DEPLOYMENT_TARGET = 9.0; 221 | VALIDATE_PRODUCT = YES; 222 | }; 223 | name = Release; 224 | }; 225 | CDF3CA6A1BA999A0005BED2C /* Debug */ = { 226 | isa = XCBuildConfiguration; 227 | buildSettings = { 228 | ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; 229 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 230 | INFOPLIST_FILE = TVKitApp/Info.plist; 231 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 232 | PRODUCT_BUNDLE_IDENTIFIER = TNS.TVKitApp; 233 | PRODUCT_NAME = "$(TARGET_NAME)"; 234 | }; 235 | name = Debug; 236 | }; 237 | CDF3CA6B1BA999A0005BED2C /* Release */ = { 238 | isa = XCBuildConfiguration; 239 | buildSettings = { 240 | ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; 241 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 242 | INFOPLIST_FILE = TVKitApp/Info.plist; 243 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 244 | PRODUCT_BUNDLE_IDENTIFIER = TNS.TVKitApp; 245 | PRODUCT_NAME = "$(TARGET_NAME)"; 246 | }; 247 | name = Release; 248 | }; 249 | /* End XCBuildConfiguration section */ 250 | 251 | /* Begin XCConfigurationList section */ 252 | CDF3CA501BA999A0005BED2C /* Build configuration list for PBXProject "TVKitApp" */ = { 253 | isa = XCConfigurationList; 254 | buildConfigurations = ( 255 | CDF3CA671BA999A0005BED2C /* Debug */, 256 | CDF3CA681BA999A0005BED2C /* Release */, 257 | ); 258 | defaultConfigurationIsVisible = 0; 259 | defaultConfigurationName = Release; 260 | }; 261 | CDF3CA691BA999A0005BED2C /* Build configuration list for PBXNativeTarget "TVKitApp" */ = { 262 | isa = XCConfigurationList; 263 | buildConfigurations = ( 264 | CDF3CA6A1BA999A0005BED2C /* Debug */, 265 | CDF3CA6B1BA999A0005BED2C /* Release */, 266 | ); 267 | defaultConfigurationIsVisible = 0; 268 | }; 269 | /* End XCConfigurationList section */ 270 | }; 271 | rootObject = CDF3CA4D1BA999A0005BED2C /* Project object */; 272 | } 273 | -------------------------------------------------------------------------------- /TVKitApp/TVKitApp/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSAppTransportSecurity 26 | 27 | NSAllowsArbitraryLoads 28 | 29 | 30 | UIRequiredDeviceCapabilities 31 | 32 | arm64 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /TVKitApp/TVKitApp/app/index.js: -------------------------------------------------------------------------------- 1 | var ItemViewController = UIViewController.extend({ 2 | viewDidLoad() { 3 | UIViewController.prototype.viewDidLoad.apply(this, arguments); 4 | 5 | var imageUrl = NSURL.URLWithString(`http://i.imgur.com/${this.fileName}.jpg`); 6 | var imageData = NSData.dataWithContentsOfURL(imageUrl); 7 | var image = UIImage.imageWithData(imageData); 8 | 9 | var imageView = UIImageView.alloc().initWithImage(image); 10 | imageView.frame = this.view.frame; 11 | imageView.contentMode = UIViewContentModeScaleAspectFill; 12 | 13 | this.view.addSubview(imageView); 14 | } 15 | }); 16 | 17 | var PageViewController = UIPageViewController.extend({ 18 | viewDidLoad() { 19 | UIPageViewController.prototype.viewDidLoad.apply(this, arguments); 20 | 21 | this.dataSource = this; 22 | 23 | this._fileNames = ['4zSb0qS', 'jCUvdej', 'bq7JddZ', 'K815GK5', 'GTeMJud', 'SEUNWpX']; 24 | this._itemViewControllerCache = new NSCache(); 25 | 26 | var initialViewController = this._itemViewControllerForIndex(0); 27 | this.setViewControllersDirectionAnimatedCompletion([initialViewController], UIPageViewControllerNavigationDirectionForward, false, null); 28 | }, 29 | 30 | pageViewControllerViewControllerBeforeViewController(pageViewController, viewController) { 31 | var index = this._indexOfItemForViewController(viewController); 32 | if (index <= 0) { 33 | return null; 34 | } 35 | 36 | return this._itemViewControllerForIndex(index - 1); 37 | }, 38 | 39 | pageViewControllerViewControllerAfterViewController(pageViewController, viewController) { 40 | var index = this._indexOfItemForViewController(viewController) 41 | if (index >= this._fileNames.length - 1) { 42 | return null; 43 | } 44 | 45 | return this._itemViewControllerForIndex(index + 1) 46 | }, 47 | 48 | presentationCountForPageViewController(pageViewController) { 49 | return this._fileNames.length; 50 | }, 51 | 52 | presentationIndexForPageViewController(pageViewController) { 53 | var currentViewController = pageViewController.viewControllers[0]; 54 | return this._indexOfItemForViewController(currentViewController); 55 | }, 56 | 57 | _indexOfItemForViewController(viewController) { 58 | var viewControllerIndex = this._fileNames.indexOf(viewController.fileName); 59 | return viewControllerIndex; 60 | }, 61 | 62 | _itemViewControllerForIndex(index) { 63 | var fileName = this._fileNames[index]; 64 | 65 | var controller = this._itemViewControllerCache.objectForKey(fileName) 66 | if (controller) { 67 | return controller; 68 | } 69 | 70 | controller = new ItemViewController(); 71 | controller.fileName = fileName; 72 | 73 | this._itemViewControllerCache.setObjectForKey(controller, fileName); 74 | return controller; 75 | } 76 | }, { 77 | protocols: [UIPageViewControllerDataSource] 78 | }); 79 | 80 | var AppDelegate = UIResponder.extend({ 81 | applicationDidFinishLaunchingWithOptions(application, launchOptions) { 82 | this._window = new UIWindow(UIScreen.mainScreen().bounds); 83 | this._window.rootViewController = PageViewController.alloc().initWithTransitionStyleNavigationOrientationOptions( 84 | UIPageViewControllerTransitionStyleScroll, UIPageViewControllerNavigationOrientationHorizontal, null); 85 | this._window.makeKeyAndVisible(); 86 | return true; 87 | } 88 | }, { 89 | protocols: [UIApplicationDelegate] 90 | }); 91 | 92 | UIApplicationMain(0, null, null, NSStringFromClass(AppDelegate.class())); 93 | -------------------------------------------------------------------------------- /TVKitApp/TVKitApp/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // TVKitApp 4 | // 5 | // Created by Jason Zhekov on 9/16/15. 6 | // Copyright © 2015 Telerik. All rights reserved. 7 | // 8 | 9 | #import "NativeScript.h" 10 | 11 | extern char metadataPtr __asm("section$start$__DATA$__TNSMetadata"); 12 | 13 | int main(int argc, char *argv[]) { 14 | @autoreleasepool { 15 | NSString *applicationPath = [NSBundle mainBundle].bundlePath; 16 | 17 | [TNSRuntime initializeMetadata:&metadataPtr]; 18 | TNSRuntime *runtime = [[TNSRuntime alloc] initWithApplicationPath:applicationPath]; 19 | 20 | #ifndef NDEBUG 21 | TNSRuntimeInspector.logsToSystemConsole = YES; 22 | #endif 23 | 24 | [runtime executeModule:@"./"]; 25 | 26 | return 0; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /screenshots/UIPageViewController.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/sample-tvOS/d73ed68614a2efd82f5cb1f22d69dda9d7abc722/screenshots/UIPageViewController.png --------------------------------------------------------------------------------