- 浏览: 2512784 次
- 性别:
- 来自: 苏州
文章分类
最新评论
-
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 1287执行npm start后报错: Error watc ... -
CocoaPods升级1.1.1报错
2016-12-15 08:39 786ERROR: While executing gem .. ... -
Visual Studio Code运行React Native报错
2016-06-13 09:43 1604React Native:0.27.2 React:15 ... -
React Native 0.27.2编译报错this._nativeModule.addListener is not a function
2016-06-12 15:21 3845React Native:0.27.2 React:15 ... -
Unable to resolve module ReactDefaultPerf from
2016-06-02 13:04 2777package.json信息如下: "reac ... -
React Native 0.26.2编译报错Undefined symbols for architecture x86_64
2016-05-26 11:15 1998React Native:0.26.2 React:15. ... -
Failed to update auto layout status: Failed to load designables from path (null)
2016-04-05 22:11 1709确保CocoaPods是0.36.1以上版本,然后在podf ... -
集成微信支付出现Undefined symbols for architecture x86_64错误
2016-03-21 13:22 1744Undefined symbols for architec ... -
React Native热部署之CodePush
2016-01-10 22:27 6223本文使用的环境是Mac OS 10.11.1、Xcode ... -
浅谈React Native中的FlexBox布局
2015-11-17 18:38 4296React Native通过一个基于FlexBox的布局引 ... -
React Native之构建一个简单的列表页
2015-10-23 14:45 2153本文中我们将创建一个简单的电影应用,这个应用将从Rotten ... -
React Native之环境搭建
2015-10-20 16:30 1435本文使用的环境是Mac O ... -
获取图片属性的方法
2015-10-18 20:43 3134很多时候我们需要获 ... -
NSCache的下标用法
2015-09-18 00:19 1209NSCache类和NSDictionary类很相似,也提供 ... -
如何给category添加属性
2015-08-16 10:41 681主要是使用了runtime中的associative机制。 ... -
UITableView的两种重用Cell方法的区别
2015-08-10 13:07 16135UITableView中有两种重用Cell的方法: - ... -
SDImageCache.m报错Unused variable 'fileName'
2015-08-04 21:56 1168GCC手册中的相关解释: unused:This att ... -
Swift调用Objective-C
2015-07-13 23:33 1220Swift调用Objective-C需要一个名为<工程 ... -
使用GCD实现倒计时
2015-07-24 21:47 1078__block int timeout = 60; // ... -
导航栏加分割线的实现
2015-07-01 22:00 1747self.view.backgroundColor = [U ...
相关推荐
本文档“一种通过进程间通信实现软件日志实时监控的方法”深入探讨了如何利用进程间通信(IPC,Inter-Process Communication)技术来达到这一目标。下面将详细阐述这个主题。 首先,我们需要理解什么是进程间通信。...
本文将深入探讨如何利用socket来实现在同一台机器上三个进程间的通信,同时涉及select()函数、信号处理以及进程重启的技术。 首先,让我们理解什么是socket。Socket是网络编程中的接口,它允许应用程序发送和接收...
MFC(Microsoft Foundation Classes)是微软提供的一个C++库,用于简化Windows应用程序开发,包括对进程间通信的支持。本篇文章将深入探讨如何使用MFC中的`SendMessage`和`PostMessage`函数来实现简单的进程间通信。...
在Linux这样的虚拟内存系统中,每个进程都有自己的地址空间,因此进程间通信是通过专门的机制来实现的。而在像UCOS这样的扁平内存系统中,所有任务共享相同的地址空间,使得进程间通信与同步机制可以在同一地址空间...
本示例以“C#与C++进程间通信”为主题,利用命名管道(Named Pipe)作为通信媒介,实现了不同类型数据结构的高效传输。 命名管道是一种在操作系统中提供半双工或全双工通信的机制,适用于在同一台计算机上的进程间...
3. **示例程序**:演示如何使用这个库进行进程间通信的实例代码。 4. **文档**:包含API参考、使用指南和示例说明。 5. **配置文件**:用于编译和构建的Makefile或CMakeLists.txt。 6. **测试用例**:验证库功能是否...
利用内存映射文件技术实现进程间通信,自pudn程序员联合开发网下载
总结来说,AIDL是Android中实现进程间通信的强大工具,它简化了服务的创建和调用,让开发者能够构建分布式系统,实现应用程序间的深度协作。理解并熟练掌握AIDL的使用,对于提升Android应用的复杂性和可扩展性至关...
总结来说,互斥锁、条件变量和共享内存是Linux下实现进程间通信的关键工具,它们共同确保了多进程环境下的数据安全和程序的正确执行。通过合理地使用这些工具,开发者能够构建出高效且可靠的多进程应用程序。在实际...
只有你允许客户端从不同的应用程序为了进程间的通信而去访问你的service,以及想在你的service处理多线程,下面为大家详细介绍下
在Visual Basic(VB)中实现进程间通信可以帮助开发者构建更复杂、多组件的应用程序。本资源包含两个子文件:“接收”和“发送”,分别代表IPC过程中的数据接收端和发送端。 在VB中,实现进程间通信有多种方法,...
在编程领域,进程间通信(IPC, Inter-Process Communication)是多个独立运行的程序之间交换数据的重要手段。在Windows操作系统环境下,利用Windows窗口消息机制进行进程间通信是一种常见的方法,尤其当涉及到跨语言...
标题"**C#实现进程间通信(使用消息队列实现)**"主要探讨的是如何使用C#语言通过消息队列来实现在不同进程之间的通信。这种方法适用于那些需要进程独立性和消息缓冲的应用场景。 在C#中,我们可以使用System....
本书详细介绍了UNIX系统中进程间通信(IPC)的各种形式,这些通信机制对于提高UNIX程序性能至关重要,同时是开发不同主机间网络应用程序的基础。 书中首先从Posix IPC和System V IPC的内部结构开始讨论。Posix IPC...
在Linux操作系统中,进程间通信(IPC,Inter-Process ...总结来说,Linux进程间通信是实现多进程协同工作、提高系统效率的关键。理解并灵活运用各种IPC方式,有助于我们设计出高效、可靠的多线程和多进程应用程序。
在现代操作系统如Linux中,进程间通信(IPC,Inter-Process Communication)是实现多进程协同工作的重要机制。通过IPC,不同进程能够共享信息、同步状态以及协作完成复杂的任务。本文将深入探讨Linux下的进程间通信...
Linux的进程通信机制源自UNIX,融合了AT&T的System V IPC和BSD的套接字机制。UNIX IPC主要包括管道、FIFO和信号,System V IPC涉及消息队列、信号量和共享内存,而Posix IPC对应Posix消息队列、信号量和共享内存。...
在.NET Framework 4.0中,...总的来说,.NET 4.0的内存共享功能为多进程通信提供了一个强大的工具,尤其适合需要高速、低延迟数据交换的应用。通过理解和熟练运用这项技术,开发者可以构建更加高效和灵活的多进程系统。
在Android系统中,进程间通信(IPC,Inter-Process Communication)是实现不同应用程序或同一应用内不同进程之间数据共享和协同工作的重要手段。"Messenger进程间通信"是一种轻量级的IPC方式,常用于简单的双向通信...
为了实现进程间的有效通信,Linux提供了多种机制,包括管道(Pipe)、有名管道(FIFO)、信号量(Semaphore)、消息队列(Message Queue)、共享内存(Shared Memory)、套接字(Socket)等。下面将对这些通信方式...