伟大的UIKit / Objective-C代码片段 [英] Great UIKit/Objective-C code snippets

查看:122
本文介绍了伟大的UIKit / Objective-C代码片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Objective-C iPhone / iPod touch / iPad开发的新手,但我开始在单行代码中发现很多功能,例如:

New to Objective-C iPhone/iPod touch/iPad development, but I'm starting to discover lots of power in one-liners of code such as this:

[UIApplication sharedApplication].applicationIconBadgeNumber = 10;

这将在您的应用iphone上显示该数字为10的独特红色通知徽章。

Which will display that distinctive red notification badge on your app iphone with the number 10.

请在这里为您的iPhone / iPod touch / iPad分享Objective-C中您最喜欢的一个或两个内容。 仅限PUBLIC API

Please share you favorite one or two-liners in Objective-C for the iPhone/iPod touch/iPad here. PUBLIC APIs ONLY.

推荐答案

在Safari中打开网址

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com/"]];

隐藏状态栏

[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];

拨打电话号码(仅限iPhone)

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://9662256888"]];

启动Apple Mail

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://mymail@myserver.com"]];

停止回应触摸事件

[[UIApplication sharedApplication] beginIgnoringInteractionEvents];

激活触摸事件

[[UIApplication sharedApplication] endIgnoringInteractionEvents];

显示网络活动指标

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

隐藏网络活动指标

[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

防止iPhone进入睡眠模式

[UIApplication sharedApplication].idleTimerDisabled = YES;

这篇关于伟大的UIKit / Objective-C代码片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆