ios开发备忘
2013-07-20 00:17
239 查看
IOS 常用开发 参考: http://www.cnblogs.com/martin1009/category/332135.html
1:直接打开app store 评论页面的URL,直接更换 后面的id号就可以
// 通过 html 打开
http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=557853602
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:@"http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=557853602"]];
// 直接通过 itunes 打开
NSString *strUrl = @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=557853602";
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:strUrl]];
2: 更改 UIPageControl 图标
[cpp] view
plaincopy
-(void)pageControlStatusImage:(int)_page{
NSArray *subview = self.firstPageControl.subviews; // 获取所有子视图
for(NSInteger i =0; i < [subview count]; i++) {
UIImageView *_dotView = [subview objectAtIndex:i];
if (i == _page) {
// image w = 6 h = 6
_dotView.image = _pageNormalImage;
} else {
_dotView.image = _pageHighlightedImage;
}
}
}
3: UIAlertView Frame
[cpp] view
plaincopy
default frame x = 0.000000, y=0.000000, w=284.000000, h=141.000000
title: x = 12.000000, y=15.000000, w=260.000000, h=23.000000
message: x = 12.000000, y=45.000000, w=260.000000, h=21.000000
left but: x = 11.000000, y=82.000000, w=127.000000, h=43.000000
right but: x = 146.000000, y=82.000000, w=127.000000, h=43.000000
4: ipad 上UIView 使用 Form Sheet Size 模式时,
UITextField, [textField resignFirstResponder] 不能关闭软键盘问题
解决方法:
在 .h .m 文件中 重写 disablesAutomaticKeyboardDismissal 方法
[cpp] view
plaincopy
- (BOOL)disablesAutomaticKeyboardDismissal;
- (BOOL)disablesAutomaticKeyboardDismissal
{
return NO;
}
如果在 UINavigationController 中使用,可以用如下方法重写,之后在 需要用到的地方 import
添加File:UINavigationController+KeyboardDismiss.h UINavigationController+KeyboardDismiss.m
[cpp] view
plaincopy
#import <Foundation/Foundation.h>
// 解决 FromSheet UIView textfiled 不能 隐藏键盘的问题
@interface UINavigationController (KeyboardDismiss)
- (BOOL)disablesAutomaticKeyboardDismissal;
@end
#import "UINavigationController+KeyboardDismiss.h"
@implementation UINavigationController(KeyboardDismiss)
- (BOOL)disablesAutomaticKeyboardDismissal
{
return NO;
}
@end
5: UIActionSheet 最后一个 按钮 点击时不太好用,一般要点击道 button 上半部才行
UIActionSheet *actionSheet = [[UIActionSheetalloc]
initWithTitle:@“aaa”
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:@"aaa",@"Cancel",nil];
//[actionSheet showInView:self.view]; ---- 把这行换掉,用下行的方法来显示
[actionSheet showInView:[UIApplicationsharedApplication].keyWindow];
6: UITableViw 的 cell 中 有 UITextFiled 控件,点击出来软件盘后,如果 UITableView 此时刷新 relaoddata,则软件盘会因为 失去 焦点而 自动隐藏
如果想要 软件盘还在,则需要 改变 UITextFiled 的焦点 到 UITableViw 之外的 另一个 UITextFiled 上即可
7: ios 设备 左上角 网络请求状态 显示/隐藏
//显示网络活动标志:
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
//隐藏网络活动标志:
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
// ---------------
1、调用 自带mail
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://admin@hzlzh.com"]];
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、调用自带 浏览器 safari
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.hzlzh.com"]];
4、调用 SMS
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://800888"]];
调用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")
}
1:直接打开app store 评论页面的URL,直接更换 后面的id号就可以
// 通过 html 打开
http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=557853602
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:@"http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=557853602"]];
// 直接通过 itunes 打开
NSString *strUrl = @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=557853602";
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:strUrl]];
2: 更改 UIPageControl 图标
[cpp] view
plaincopy
-(void)pageControlStatusImage:(int)_page{
NSArray *subview = self.firstPageControl.subviews; // 获取所有子视图
for(NSInteger i =0; i < [subview count]; i++) {
UIImageView *_dotView = [subview objectAtIndex:i];
if (i == _page) {
// image w = 6 h = 6
_dotView.image = _pageNormalImage;
} else {
_dotView.image = _pageHighlightedImage;
}
}
}
3: UIAlertView Frame
[cpp] view
plaincopy
default frame x = 0.000000, y=0.000000, w=284.000000, h=141.000000
title: x = 12.000000, y=15.000000, w=260.000000, h=23.000000
message: x = 12.000000, y=45.000000, w=260.000000, h=21.000000
left but: x = 11.000000, y=82.000000, w=127.000000, h=43.000000
right but: x = 146.000000, y=82.000000, w=127.000000, h=43.000000
4: ipad 上UIView 使用 Form Sheet Size 模式时,
UITextField, [textField resignFirstResponder] 不能关闭软键盘问题
解决方法:
在 .h .m 文件中 重写 disablesAutomaticKeyboardDismissal 方法
[cpp] view
plaincopy
- (BOOL)disablesAutomaticKeyboardDismissal;
- (BOOL)disablesAutomaticKeyboardDismissal
{
return NO;
}
如果在 UINavigationController 中使用,可以用如下方法重写,之后在 需要用到的地方 import
添加File:UINavigationController+KeyboardDismiss.h UINavigationController+KeyboardDismiss.m
[cpp] view
plaincopy
#import <Foundation/Foundation.h>
// 解决 FromSheet UIView textfiled 不能 隐藏键盘的问题
@interface UINavigationController (KeyboardDismiss)
- (BOOL)disablesAutomaticKeyboardDismissal;
@end
#import "UINavigationController+KeyboardDismiss.h"
@implementation UINavigationController(KeyboardDismiss)
- (BOOL)disablesAutomaticKeyboardDismissal
{
return NO;
}
@end
5: UIActionSheet 最后一个 按钮 点击时不太好用,一般要点击道 button 上半部才行
UIActionSheet *actionSheet = [[UIActionSheetalloc]
initWithTitle:@“aaa”
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:@"aaa",@"Cancel",nil];
//[actionSheet showInView:self.view]; ---- 把这行换掉,用下行的方法来显示
[actionSheet showInView:[UIApplicationsharedApplication].keyWindow];
6: UITableViw 的 cell 中 有 UITextFiled 控件,点击出来软件盘后,如果 UITableView 此时刷新 relaoddata,则软件盘会因为 失去 焦点而 自动隐藏
如果想要 软件盘还在,则需要 改变 UITextFiled 的焦点 到 UITableViw 之外的 另一个 UITextFiled 上即可
7: ios 设备 左上角 网络请求状态 显示/隐藏
//显示网络活动标志:
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
//隐藏网络活动标志:
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
// ---------------
1、调用 自带mail
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://admin@hzlzh.com"]];
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、调用自带 浏览器 safari
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.hzlzh.com"]];
4、调用 SMS
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://800888"]];
调用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")
}
相关文章推荐
- ios开发问题备忘
- 【备忘】 iOS开发UI基础 UI高级开发(完整)视频下载
- ios 开发常用代码 (备忘)
- 【备忘】2017年最新React开发Native开发安卓与ios平台的GitHub App视频教程
- IOS开发备忘
- [备忘]IOS开发中关闭键盘的两种常用方法
- iOS 蓝牙开发备忘
- 自己觉得比较好的学习iOS开发的网站,收录备忘
- ios越狱开发预研备忘
- 【iOS开发】 AudioSession设置, 切换扬声器和听筒详解-保留其他应用音乐(备忘)
- IOS开发~FMDB备忘
- ios 开发中对于ipad 和iPhone的判断逻辑 备忘
- 【备忘】IOS(iPhone)开发中级视频教程下载
- ios开发备忘
- IOS开发中,IAP(In-App Purchase, 程序内置收费)相关总结, 及备忘
- IOS开发中,IAP(In-App Purchase, 程序内置收费)相关总结及备忘
- 【备忘】 iOS开发UI基础 UI高级开发(完整)视频下载
- 【iOS开发】iO7以上CIFilter生成二维码(备忘)
- ios开发备忘
- iOS开发资源:推送通知相关开源项目--PushSharp、APNS-PHP以及Pyapns等