iPhone开发技巧之私有API(8)— UIApplication
iPhone开发技巧之私有API(8)--- UIApplication
如果我们继承了UIApplication,就可以捕捉到应用程序发生的各种事件。首先,像下面这样实现你的 main 方法。
1 2 3 4 5 6
int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, @"MyApplication", @"MyAppDelegate"); [pool release];[......]
iPhone开发技巧之私有API(7)— 用UIWebView访问BASIC认证的页面
iPhone开发技巧之私有API(7)--- 用UIWebView访问BASIC认证的页面
比如类似下面的 URL,
1
http://user:password@www.example.com/
需要用户的认证,如果用 UIWebView 访问这样的页面,可以使用下面的委托方法。
1
- (void)webView:(id)fp8 resource:(id)fp12 didReceiveAuthenticationChallenge:(id)fp16 fromDataSource:(id)fp20;
具体参数形式如下。
1 2 3 4
- (void)webView:(UIWebView *)webView resource:(NSObject *)resource[......]
iPhone开发技巧之私有API(6)— 设置UIWebView中的User-Agent
iPhone开发技巧之私有API(6)--- 设置UIWebView中的User-Agent
现在许多网站专门针对iPhone做了专用的页面,比如用Safari访问雅虎看到的是iPhone的页面,可是在自己的程序中用UIWebView,却是一般在PC上表示的页面。
像这样的网站,都是通过浏览器的 User-Agent 来切换页面的。但是 UIWebView 中不能设置 User-Agent,所以只可能看到普通的PC页面。
不同通过下面的私有API方法可以设置 User-Agent。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#import <objc/runtime.h> @interface MyWebViewController : UIViewController { IBOutlet UIWebV[......]
iPhone开发技巧之私有API(5)— UISegmentedControl
iPhone开发技巧之私有API(5)--- UISegmentedControl
直接指定 UISegmentedControl 的 segmentedControlStyle 属性值,可以得到一些非公开的设置。
1 2 3 4
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems: [NSArray arrayWithObjects:@"First", @"Second", @"Third", nil]]; segmentedControl.segmentedControlStyle = 3;
[......]
iPhone开发技巧之私有API(4)— UIBarButtonItem
iPhone开发技巧之私有API(4)--- UIBarButtonItem
今天介绍一下 UIBarButtonItem 的特殊用法。
如上所示,UIBarButtonSystemItem 的 100 ~ 110 就是系统提供的一些未公开的标准icon。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
NSMutableArray *items = [NSMutableArray array]; UIBarButtonItem *item = nil; for (int i = 100; i <= 109; i++) { item = [[UIBarButtonItem alloc] initWithBarB[......]
iPhone开发技巧之私有API(3)— UIButton
iPhone开发技巧之私有API(3)--- UIButton
如下图所示,指定 100 以上的UIButton的buttonWithType:就可以得到非公开的按钮风格。
- 其中 100 ~ 102 是 UINavigationButton 风格的按钮
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
UIButton *button; button = [UIButton buttonWithType:100]; button.frame = CGRectMake(10.0f, 10.0f, button.frame.size.width, button.frame.size.height); [button setTitle:[NSString stringWithUTF8String:"10[......]
iPhone开发技巧之数据篇(1)— 使用正则表达式
iPhone开发技巧之数据篇(1)--- 使用正则表达式
在处理字符串的时候,常常会用到正则表达式,在iphone os上也不例外。使用 RegexKit Framework 就可以了。在这里下载RegexKitLite。
解压 RegexKitLite-4.0.tar.bz2 :
1 2 3 4 5 6 7 8 9 10
RegexKitLite.h RegexKitLite.m RegexKitLite.html examples RKLMatchEnumerator.h RKLMatchEnumerator.m NSString-HexConversion.h NSS[......]
iPhone开发技巧之私有API(2)— UITableView
iPhone开发技巧之私有API(2)--- UITableView
像下面 UITableView 中实现复数选择的设置,需要用到 Undocumented API。
首先,如下所示,在实现了 UITableViewDelegate 的类中实现下面的方法。
1 2 3 4
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { return 3; }
其中 UITableViewCellEditingStyle 的定义在 SDK 中如下所示:
1 2 3 4 5
typedef enum { UITa[......]
iPhone开发技巧之私有API(1) — 设备相关信息
iPhone开发技巧之私有API(1) --- 设备相关信息
在iPhone开发技巧之环境篇(8)--- 使用非公开的API一章中我们已经学会了怎样得到非公开PAI头文件的方法。这里将手头收集到的各种应用方法做一个总结,希望对您 有所帮助。
使用这些API是要冒一些风险的,一是不会通过 App Stroe 的审核,二是以后比一定还能在高版本的SDK中使用。所以使用之前,三思而行。
先总结一些与设备相关的API。
IMEI
可以在这里下载NetworkController.h, 或者使用你自己dump的版本。使用如下:
1 2 3 4 5 6 7 8
#import "NetworkCo[......]
iPhone开发技巧之网络篇(5)— 使用libcurl连接https服务器
iPhone开发技巧之网络篇(5)--- 使用libcurl连接https服务器
问题
你是否也想让自己的 iPhone 应用程序连接 https 服务器呢?下面我就介绍一下其使用方法。
通常使用 Objective-C 的 NSURLConnection 连接有证明书的 https 服务器时会出现验证错误,我们可以使用私有API — setAllowsAnyHTTPSCertificate:forHost 来解决这个问题。如果是 Cocoa 的应用程序应该是没有什么问题,但是用在 iPhone 上,很可能过不了 App Store 的审查。
所以这里我们使用 libcurl 来完成在 iph[......]