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

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

问题描述

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;

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

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

解决方案

Open an URL in Safari

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

Hide the status bar

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

Dial a Phone Number (iPhone Only)

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

Launch the Apple Mail

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

stop responding to touch events

[[UIApplication sharedApplication] beginIgnoringInteractionEvents];

active the touch events

[[UIApplication sharedApplication] endIgnoringInteractionEvents];

Show the network Activity Indicator

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

Hide the network Activity Indicator

[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

Prevents iPhone goes into sleep mode

[UIApplication sharedApplication].idleTimerDisabled = YES;

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

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