// // MailViewController.m // Mail // // Created by david on 13-8-2. // Copyright (c) 2013年 WalkerFree. All rights reserved. //
#import "MailViewController.h"
@interfaceMailViewController ()
@end
@implementationMailViewController
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. }
- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }
- (IBAction)showMailPicker:(id)sender { if([MFMailComposeViewController canSendMail]){ [self displayMailComposerSheet]; }else{ NSLog(@"Device not configured to send SMS."); } }
- (void)displayMailComposerSheet { MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; [picker setSubject:@"Hello from California!"]; // Set up recipients NSArray *toRecipients = [NSArray arrayWithObject:@"xx@xx"]; NSArray *ccRecipients = [NSArray arrayWithObjects:@"xx@xx", @"xx@xx", nil]; NSArray *bccRecipients = [NSArray arrayWithObject:@"xx@xx"]; [picker setToRecipients:toRecipients]; [picker setCcRecipients:ccRecipients]; [picker setBccRecipients:bccRecipients]; // Attach an image to the email NSString *path = [[NSBundle mainBundle] pathForResource:@"rainy" ofType:@"jpg"]; NSData *myData = [NSData dataWithContentsOfFile:path]; [picker addAttachmentData:myData mimeType:@"image/jpeg" fileName:@"rainy"]; // Fill out the email body text NSString *emailBody = @"It is raining in sunny California!"; [picker setMessageBody:emailBody isHTML:NO]; [self presentViewController:picker animated:YES completion:NULL]; }
#pragma mark - delegate Methods
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error{ // Notifies users about errors associated with the interface switch (result) { case MFMailComposeResultCancelled: NSLog(@"Result: Mail sending canceled") ; break; case MFMailComposeResultSaved: NSLog(@"Result: Mail saved") ; break; case MFMailComposeResultSent: NSLog(@"Result: Mail sent") ; break; case MFMailComposeResultFailed: NSLog(@"Result: Mail sending failed") ; break; default: NSLog(@"Result: Mail not sent") ; break; } [self dismissViewControllerAnimated:YES completion:NULL]; }
for p in Person.objects.raw('SELECT * FROM myapp_person'): print(p)
官方提示不要使用下面这种方式
1 2 3
lname = 'Doe' query = 'SELECT * FROM myapp_person WHERE last_name = %s' % lname Person.objects.raw(query)
2,Executing custom SQL directly
Sometimes even Manager.raw() isn’t quite enough: you might need to perform queries that don’t map cleanly to models, or directly execute UPDATE, INSERT, or DELETE queries.
是的,有时候Raw Sql Queries是满足不了我们的需求的,那么我们就直接执行一下好了。
1 2 3 4 5
cursor = connection.cursor() cursor.execute("UPDATE myapp_person SET first_name = 1 WHERE first_name = %s", [self.bar]) cursor.execute("SELECT `last_name` FROM myapp_person WHERE last_name = %s", [self.baz]) row = cursor.fetchone() print_r(row)
layoutSubviews何时调用的问题,这个方法是当你需要在调整subview的大小的时候需要重写(我这个翻译不严谨,以下是原文:You should override this method only if the autoresizing behaviors of the subviews do not offer the behavior you want.),但有时候经常指望它被调用的时候没被调用,不希望它被调用的时候被调用了,搞的很上火。根据国外社区一个人帖子,做了总结性翻译。
57:这种型号的尺寸的图片主要用于(Homescreen icon on iPhone/iPod touch),在iPhone/iPod touch的主屏幕上
72:这种型号的尺寸的图片主要用于(Homescreen icon on iPad),在iPad的主屏幕上
114:上面的一倍,这种尺寸的图片用于(Homescreen icon on iPhone Retina),在iPhone Retina的主屏幕上
65:这种型号的图片主要用于(Icon in Spotlight and Settings app on iPhone/iPod touch and icon in Settings app on iPad),说到Spotlight这个,大家都知道的,没错就是搜索时,出现的,如果不知道,说明你安装的应用还不够多,哈哈
50:这个大小的图片,(Icon in Spotlight on iPad),是存在于iPad上的,说的跟上面那个型号差不多,就是小了点,但是这个很重要,尤其是在ios开发中
58:这个尺寸的图片,用过iPhone5的或者有Retina屏都知道(Icon in Spotlight and Settings app on iPhone Retina),没错,就是在那里使用的。
114:这个尺寸的介绍是这样的(Icon in iTunes for Ad Hoc distribution builds),估计是跟开发有关点的,但是事实上在iPunes里面也能看得到的,
- (void)tileLabelsFromMinX:(CGFloat)minimumVisibleX toMaxX:(CGFloat)maximumVisibleX { // the upcoming tiling logic depends on there already being at least one label in the visibleLabels array, so // to kick off the tiling we need to make sure there's at least one label if ([self.visibleLabels count] == 0) { [self placeNewLabelOnRight:minimumVisibleX]; } // add labels that are missing on right side UILabel *lastLabel = [self.visibleLabels lastObject]; CGFloat rightEdge = CGRectGetMaxX([lastLabel frame]); while (rightEdge < maximumVisibleX) { rightEdge = [self placeNewLabelOnRight:rightEdge]; } // add labels that are missing on left side UILabel *firstLabel = self.visibleLabels[0]; CGFloat leftEdge = CGRectGetMinX([firstLabel frame]); while (leftEdge > minimumVisibleX) { leftEdge = [self placeNewLabelOnLeft:leftEdge]; } // remove labels that have fallen off right edge lastLabel = [self.visibleLabels lastObject]; while ([lastLabel frame].origin.x > maximumVisibleX) { [lastLabel removeFromSuperview]; [self.visibleLabels removeLastObject]; lastLabel = [self.visibleLabels lastObject]; } // remove labels that have fallen off left edge firstLabel = self.visibleLabels[0]; while (CGRectGetMaxX([firstLabel frame]) < minimumVisibleX) { [firstLabel removeFromSuperview]; [self.visibleLabels removeObjectAtIndex:0]; firstLabel = self.visibleLabels[0]; } }
- (void)tileLabelsFromMinX:(CGFloat)minimumVisibleX toMaxX:(CGFloat)maximumVisibleX { // the upcoming tiling logic depends on there already being at least one label in the visibleLabels array, so // to kick off the tiling we need to make sure there's at least one label if ([self.visibleLabels count] == 0) { [self placeNewLabelOnRight:minimumVisibleX]; } // add labels that are missing on right side UILabel *lastLabel = [self.visibleLabels lastObject]; CGFloat rightEdge = CGRectGetMaxX([lastLabel frame]); while (rightEdge < maximumVisibleX) { rightEdge = [self placeNewLabelOnRight:rightEdge]; } // add labels that are missing on left side UILabel *firstLabel = self.visibleLabels[0]; CGFloat leftEdge = CGRectGetMinX([firstLabel frame]); while (leftEdge > minimumVisibleX) { leftEdge = [self placeNewLabelOnLeft:leftEdge]; } // remove labels that have fallen off right edge lastLabel = [self.visibleLabels lastObject]; while ([lastLabel frame].origin.x > maximumVisibleX) { [lastLabel removeFromSuperview]; [self.visibleLabels removeLastObject]; lastLabel = [self.visibleLabels lastObject]; } // remove labels that have fallen off left edge firstLabel = self.visibleLabels[0]; while (CGRectGetMaxX([firstLabel frame]) < minimumVisibleX) { [firstLabel removeFromSuperview]; [self.visibleLabels removeObjectAtIndex:0]; firstLabel = self.visibleLabels[0]; } }