ios 設定亮度、聲音;調用發簡訊、郵件、打電話

來源:互聯網
上載者:User

標籤:style   http   java   color   使用   檔案   

一,設定亮度

[[UIScreen mainScreen] setBrightness:0.5];//0.0~1.0

二,設定聲音

1,添加 MediaPlayer.framework 架構

2,在需要的檔案中匯入標頭檔,#import <MediaPlayer/MediaPlayer.h>

3,[[MPMusicPlayerController applicationMusicPlayer] setVolume: 0.5];//0.0~1.0

三,調用發簡訊、郵件、打電話

1、調用 內建mail
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://[email protected]"]];

2、調用 電話phone
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8008808888"]];
iOS應用內撥打到電話結束後返回應用
一般在應用中撥打到電話的方式是:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://123456789"]];

使用這種方式撥打到電話時,當使用者結束通話後,iphone介面會停留在電話介面。
用如下方式,可以使得使用者結束通話後自動返回到應用:
UIWebView*callWebview =[[UIWebView alloc] init];
NSURL *telURL =[NSURL URLWithString:@"tel:10086"];// 貌似tel:// 或者 tel: 都行
[callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];
//記得添加到view上
[self.view addSubview:callWebview];

 還有一種私人方法:(可能不能通過審核)
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://10086"]];

3、調用 SMS
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://800888"]];

4、調用內建 瀏覽器 safari
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.hzlzh.com"]];

調用phone可以傳遞號碼,調用SMS 只能設定號碼,不能初始化SMS內容。

若需要傳遞內容可以做如下操作:
加入:MessageUI.framework

#import <MessageUI/MFMessageComposeViewController.h>

實現代理:MFMessageComposeViewControllerDelegate

調用sendSMS函數
//內容,收件者清單
- (void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSArray *)recipients
{

MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];

if([MFMessageComposeViewController canSendText])

{

controller.body = bodyOfMessage;

controller.recipients = recipients;

controller.messageComposeDelegate = self;

[self presentModalViewController:controller animated:YES];

}

}

// 處理髮送完的響應結果
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
[self dismissModalViewControllerAnimated:YES];

if (result == MessageComposeResultCancelled)
NSLog(@"Message cancelled")
else if (result == MessageComposeResultSent)
NSLog(@"Message sent") 
else 
NSLog(@"Message failed") 
}

預設傳送簡訊的介面為英文的,解決辦法為:
在.xib 中的Localization添加一組chinese就ok了

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.