- 浏览: 2553266 次
- 性别:
- 来自: 苏州
文章分类
最新评论
-
jsntghf:
peio 写道这个怎么运行?Ruby On Rails的环境搭 ...
多文件上传之uploadify -
peio:
这个怎么运行?
多文件上传之uploadify -
往事如烟1:
我的项目是自己init了一个原始的project,之后将ver ...
React Native热部署之CodePush -
jsntghf:
往事如烟1 写道我按照你的说明进行,发现app退出之后,在进入 ...
React Native热部署之CodePush -
往事如烟1:
我按照你的说明进行,发现app退出之后,在进入不正确,请问是什 ...
React Native热部署之CodePush
在iOS里,程序之间都是相互隔离的,目前并没有一个有效的方式来做程序间通信,幸好iOS程序可以很方便的注册自己的URL Scheme,这样就可以通过打开特定URL的方式来传递参数给另外一个程序。
至于,如何注册自己的URL Scheme,可以参考:自定义URL Scheme。
下面,看一个具体的示例。
假设有两个应用:A和B,A应用有两个UITableView,一个是字母类型的,另一个是数字类型的,B应用有两个按钮,一个用来打开A应用的字母列表,另一个用来打开A应用的数字列表,其中,A应用的Info.plist信息如下:
A应用的所有代码如下:
NavigationAppDelegate.h
#import <UIKit/UIKit.h> @class NavigationViewController; @interface NavigationAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; UINavigationController *viewController; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet UINavigationController *viewController; @end
NavigationAppDelegate.m
#import "NavigationAppDelegate.h" #import "NavigationViewController.h" #import "NumberViewController.h" @implementation NavigationAppDelegate @synthesize window; @synthesize viewController; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NavigationViewController *nav = [[NavigationViewController alloc] init]; viewController = [[UINavigationController alloc] initWithRootViewController:nav]; [self.window addSubview:viewController.view]; [self.window makeKeyAndVisible]; [nav release]; return YES; } - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { if ([[url host] isEqualToString:@"com.aurora.nav"]) { NSString *viewId = [[url query] substringFromIndex:[[url query] rangeOfString:@"viewId="].location + 7]; if ([viewId isEqualToString:@"letters"]){ NavigationViewController *nav = [[NavigationViewController alloc] init]; [self.viewController pushViewController:nav animated:YES]; [nav release]; } else { NumberViewController *nav = [[NumberViewController alloc] init]; [self.viewController pushViewController:nav animated:YES]; [nav release]; } } return YES; } - (void)dealloc { [viewController release]; [window release]; [super dealloc]; } @end
NavigationViewController.h
#import <UIKit/UIKit.h> @interface NavigationViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> { NSArray *array; } @property(nonatomic, retain) NSArray *array; @end
NavigationViewController.m
#import "NavigationViewController.h" @implementation NavigationViewController @synthesize array; - (void)viewDidLoad { [super viewDidLoad]; self.title = @"Letters"; NSArray *letters = [[NSArray alloc] initWithObjects:@"A", @"B", @"C", @"D", @"E", @"F", @"G", nil]; self.array = letters; [letters release]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [array count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } cell.textLabel.text = [array objectAtIndex:[indexPath row]]; return cell; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)viewDidUnload { array = nil; } - (void)dealloc { [array release]; array = nil; [super dealloc]; } @end
NumberViewController.h
#import <UIKit/UIKit.h> @interface NumberViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> { NSArray *array; } @property(nonatomic, retain) NSArray *array; @end
NumberViewController.m
#import "NumberViewController.h" @implementation NumberViewController @synthesize array; - (void)viewDidLoad { [super viewDidLoad]; self.title = @"Numbers"; NSArray *numbers = [[NSArray alloc] initWithObjects:@"1", @"2", @"3", @"4", @"5", @"6", @"7", nil]; self.array = numbers; [numbers release]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [array count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } cell.textLabel.text = [array objectAtIndex:[indexPath row]]; return cell; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)viewDidUnload { array = nil; } - (void)dealloc { [array release]; array = nil; [super dealloc]; } @end
B应用的所有代码如下:
RequestViewController.h
#import <UIKit/UIKit.h> @interface RequestViewController : UIViewController { } - (IBAction) goToLetters; - (IBAction) goToNumbers; @end
RequestViewController.m
#import "RequestViewController.h" @implementation RequestViewController - (IBAction) goToLetters{ NSString *str = @"nav://com.aurora.nav?viewId=%@"; NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:str, @"letters"]]; [[UIApplication sharedApplication] openURL:url]; } - (IBAction) goToNumbers{ NSString *str = @"nav://com.aurora.nav?viewId=%@"; NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:str, @"numbers"]]; [[UIApplication sharedApplication] openURL:url]; } @end
发表评论
-
Error watching file for changes: EMFILE
2016-12-15 11:57 1314执行npm start后报错: Error watc ... -
CocoaPods升级1.1.1报错
2016-12-15 08:39 804ERROR: While executing gem .. ... -
Visual Studio Code运行React Native报错
2016-06-13 09:43 1626React Native:0.27.2 React:15 ... -
React Native 0.27.2编译报错this._nativeModule.addListener is not a function
2016-06-12 15:21 3874React Native:0.27.2 React:15 ... -
Unable to resolve module ReactDefaultPerf from
2016-06-02 13:04 2798package.json信息如下: "reac ... -
React Native 0.26.2编译报错Undefined symbols for architecture x86_64
2016-05-26 11:15 2040React Native:0.26.2 React:15. ... -
Failed to update auto layout status: Failed to load designables from path (null)
2016-04-05 22:11 1732确保CocoaPods是0.36.1以上版本,然后在podf ... -
集成微信支付出现Undefined symbols for architecture x86_64错误
2016-03-21 13:22 1757Undefined symbols for architec ... -
React Native热部署之CodePush
2016-01-10 22:27 6266本文使用的环境是Mac OS 10.11.1、Xcode ... -
浅谈React Native中的FlexBox布局
2015-11-17 18:38 4316React Native通过一个基于FlexBox的布局引 ... -
React Native之构建一个简单的列表页
2015-10-23 14:45 2173本文中我们将创建一个简单的电影应用,这个应用将从Rotten ... -
React Native之环境搭建
2015-10-20 16:30 1457本文使用的环境是Mac O ... -
获取图片属性的方法
2015-10-18 20:43 3154很多时候我们需要获 ... -
NSCache的下标用法
2015-09-18 00:19 1226NSCache类和NSDictionary类很相似,也提供 ... -
如何给category添加属性
2015-08-16 10:41 699主要是使用了runtime中的associative机制。 ... -
UITableView的两种重用Cell方法的区别
2015-08-10 13:07 16166UITableView中有两种重用Cell的方法: - ... -
SDImageCache.m报错Unused variable 'fileName'
2015-08-04 21:56 1186GCC手册中的相关解释: unused:This att ... -
Swift调用Objective-C
2015-07-13 23:33 1239Swift调用Objective-C需要一个名为<工程 ... -
使用GCD实现倒计时
2015-07-24 21:47 1095__block int timeout = 60; // ... -
导航栏加分割线的实现
2015-07-01 22:00 1777self.view.backgroundColor = [U ...
相关推荐
本文档“一种通过进程间通信实现软件日志实时监控的方法”深入探讨了如何利用进程间通信(IPC,Inter-Process Communication)技术来达到这一目标。下面将详细阐述这个主题。 首先,我们需要理解什么是进程间通信。...
这个"毕业设计,包含简单的内存管理、进程调度、进程间通信实现.zip"文件很可能是一个学生或研究者为了理解操作系统核心概念而创建的一个小型模拟系统。下面我们将深入探讨这三个关键知识点。 1. 内存管理: 内存...
总结来说,本文提出的基于Java的进程间异步通信系统在设计上充分考虑了分布式应用的特性,通过优化的通信架构和智能的消息处理机制,实现了高效的进程间通信。该系统不仅提高了通信效率和可靠性,还为分布式应用的...
本示例中,我们关注的是利用消息队列这一特定的IPC机制,来实现在Linux系统下的进程间通信。消息队列提供了异步通信的能力,使得进程可以在不同时刻发送和接收消息,而无需相互等待。 首先,我们有两个进程,进程A...
MFC(Microsoft Foundation Classes)是微软提供的一个C++库,用于简化Windows应用程序开发,包括对进程间通信的支持。本篇文章将深入探讨如何使用MFC中的`SendMessage`和`PostMessage`函数来实现简单的进程间通信。...
本示例以“C#与C++进程间通信”为主题,利用命名管道(Named Pipe)作为通信媒介,实现了不同类型数据结构的高效传输。 命名管道是一种在操作系统中提供半双工或全双工通信的机制,适用于在同一台计算机上的进程间...
3. **示例程序**:演示如何使用这个库进行进程间通信的实例代码。 4. **文档**:包含API参考、使用指南和示例说明。 5. **配置文件**:用于编译和构建的Makefile或CMakeLists.txt。 6. **测试用例**:验证库功能是否...
总结来说,AIDL是Android中实现进程间通信的强大工具,它简化了服务的创建和调用,让开发者能够构建分布式系统,实现应用程序间的深度协作。理解并熟练掌握AIDL的使用,对于提升Android应用的复杂性和可扩展性至关...
VC利用管道和多线程实现进程间通信 VC++环境下利用管道和线程实现进程间通信的技术是指在Windows操作系统中,使用Visual C++语言,通过创建管道和线程来实现进程之间的通信。这种技术可以在不同的进程之间实现信息...
进程间通信(IPC,Inter-Process Communication)是操作系统中一种重要的技术,允许不同进程之间交换数据...通过对这些通信机制的深入理解和应用,开发者能够更好地设计和实现多进程应用程序,提高系统的并行性和效率。
在Visual Basic(VB)中实现进程间通信可以帮助开发者构建更复杂、多组件的应用程序。本资源包含两个子文件:“接收”和“发送”,分别代表IPC过程中的数据接收端和发送端。 在VB中,实现进程间通信有多种方法,...
C++ 用共享内存实现进程间通信 所用IDE为VS2003
本文将详细探讨如何通过VC++使用内存映射来实现进程间通信。 内存映射是一种技术,它允许一个文件或部分文件被映射到进程的虚拟地址空间,使得多个进程可以同时访问同一块物理内存,从而实现数据共享。在Windows中...
标题"**C#实现进程间通信(使用消息队列实现)**"主要探讨的是如何使用C#语言通过消息队列来实现在不同进程之间的通信。这种方法适用于那些需要进程独立性和消息缓冲的应用场景。 在C#中,我们可以使用System....
本书详细介绍了UNIX系统中进程间通信(IPC)的各种形式,这些通信机制对于提高UNIX程序性能至关重要,同时是开发不同主机间网络应用程序的基础。 书中首先从Posix IPC和System V IPC的内部结构开始讨论。Posix IPC...
《UNIX网络编程 第2版 第2卷 进程间通信》是UNIX系统下进行网络编程不可或缺的经典著作,尤其在深入理解和实践进程间通信(IPC,Inter-Process Communication)方面提供了丰富的知识和技术指导。本书详细阐述了如何...
在编程领域,进程间通信(IPC, Inter-Process Communication)是多个独立运行的程序之间交换数据的重要手段。在Windows操作系统环境下,利用Windows窗口消息机制进行进程间通信是一种常见的方法,尤其当涉及到跨语言...
Linux的进程通信机制源自UNIX,融合了AT&T的System V IPC和BSD的套接字机制。UNIX IPC主要包括管道、FIFO和信号,System V IPC涉及消息队列、信号量和共享内存,而Posix IPC对应Posix消息队列、信号量和共享内存。...
代码实现了进程间通信的基本框架,方便应用于不同平台间进程通信。 基于此代码可以轻松开发出系统守护进程以及进程间通信程序 代码经过大量测试并应用于量产项目,具有高可靠性和稳定性。 适用于 Linux X86、Linux ...