IOS系统所有的字体调用 NSLog(@"familyNames==%@ fontNamesForFamilyName=%@",[UIFont familyNames],[UIFont fontNamesForFamilyName:@"Helvetica Neue"]);
Example :计时器格式的字体 [UIFont fontWithName:@"DB LCD Temp" size:100.0]
把程序内容分享到社交网站上Facebook,Twitter上
SLComposeViewController *tweetViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
NSString *total = [DragData doMeditationTime:[log.meditationTime timeIntervalSinceReferenceDate]];
NSString *interval = [DragData doMeditationTime:[log.interval timeIntervalSinceReferenceDate]];
NSString *twitterStr = [NSString stringWithFormat:@"Finished my meditation, %@ in total, %@ an interval.",total, interval];
[tweetViewController setInitialText:twitterStr];
[tweetViewController addURL:[NSURL URLWithString:@"https://itunes.apple.com/us/app/meditation-timer-for-ipad/id514271769?mt=8"]];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result)
{
[tweetViewController dismissViewControllerAnimated:YES completion:^{
}];
};
[tweetViewController setCompletionHandler:myBlock];
if (tweetViewController == nil)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Twitter account" message:@"There is no Twitter account configured. You can add or create a Twitter account in Settings." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
return;
}else
{
[self presentViewController:tweetViewController animated:YES completion:nil];
}
statusBar消失的问题 解决方法在 info------>View controller-based status bar appearance 设为YES
关于cell的重用问题,防止在cell上加载多次子视图
UIImageView *imageView=(UIImageView *)[cell viewWithTag:111111];
if (![cell viewWithTag:111111])
{
imageView=[[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 512, 670)] autorelease];
imageView.tag=111111;
[cell addSubview:imageView];
}
获取工程中一个素材或者文件的绝对路径
path=[[NSBundle mainBundle] pathForResource:[self.imageArray objectAtIndex:indexPath.row] ofType:@"jpg"];
去除字符串中的空格NSString *trimedString = [self.nameField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
晃动设备可随机切换图片
CMMotionManager *manager = [[CMMotionManager alloc]init];
manager.accelerometerUpdateInterval=1.0/5.0;
[manager startAccelerometerUpdates];
[manager startAccelerometerUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) {
if (fabsf(manager.accelerometerData.acceleration.x) > 1.5 || fabsf(manager.accelerometerData.acceleration.y) > 1.5 || fabsf(manager.accelerometerData.acceleration.z) > 1.5)
{
[self setBackgroundViewIsShake:YES]; //响应方法摇动设备时调用
}
}];
读取本地的Html文件进行显示
NSString *path = [[NSBundle mainBundle] pathForResource:@"meditation_help_ipad" ofType:@"html"];
NSFileHandle *readHandle = [NSFileHandle fileHandleForReadingAtPath:path];
NSString *htmlString = [[NSString alloc] initWithData:
[readHandle readDataToEndOfFile] encoding:NSUTF8StringEncoding];
self.view.backgroundColor= kBackgroundColor;
UIWebView *webView=[[UIWebView alloc]init];
webView.opaque = NO;
webView.backgroundColor = [UIColor clearColor];
[webView loadHTMLString:htmlString baseURL:nil];
[self.view addSubview:webView];