re_reference 发表于 2013-1-30 20:25:41

IOS 代码片段 (Update!)

1、分享到Facebook连接。
http://m.facebook.com/sharer.php?u=URL&t=标题

2、移除ABPeoplePickerNavigationController右边的Cancel按钮
    ABPeoplePickerNavigationController *picker = [ init];    picker.delegate = self;.................- (void)navigationController:(UINavigationController *)navigationController      willShowViewController:(UIViewController *)viewController                  animated:(BOOL)animated {    // Here we want to remove the 'Cancel' button, but only if we're showing    // either of the ABPeoplePickerNavigationController's top two controllers    viewController.navigationItem.rightBarButtonItem = nil;}
摘自:http://stackoverflow.com/questions/1611499/abpeoplepickernavigationcontroller-remove-cancel-button-without-using-privat

3.ios multipart request related code:
- (void) uploadPicture{      UIImage *img = ;    NSData *imageData = UIImageJPEGRepresentation(img, 90);    //Here i tried 2 ways of getting the data for uploading, but both don't work.      // create the URL    NSURL *postURL = ;      // create the connection    NSMutableURLRequest *postRequest = ;      // change type to POST (default is GET)    ;      // just some random text that will never occur in the body    NSString *stringBoundary = @"0xKhTmLbOuNdArY---This_Is_ThE_BoUnDaRyy---pqo";      // header value, user session ID added    NSString *headerBoundary = ;      // set header    ;    // create data    NSMutableData *postBody = ;      // text part    dataUsingEncoding:NSUTF8StringEncoding]];    dataUsingEncoding:NSUTF8StringEncoding]];    ];    ];      // media/image part    dataUsingEncoding:NSUTF8StringEncoding]];    dataUsingEncoding:NSUTF8StringEncoding]];    ];    ];    ];      // final boundary    dataUsingEncoding:NSUTF8StringEncoding]];    NSString *s = [ initWithData:postBody encoding:NSASCIIStringEncoding];    NSLog(@"%@", s);      // add body to post    ;      // pointers to some necessary objects    NSURLResponse* response;    NSError* error;      // synchronous filling of data from HTTP POST response    NSData *responseData = ;       completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {      if (error)      {            NSLog(@"Error: %@", );      }                // convert data into string      NSString *responseString = [ initWithBytes:                                                            length:                                                          encoding:NSUTF8StringEncoding];                // see if we get a welcome result      NSLog(@"%@", responseString);    }];}
See http://stackoverflow.com/questions/8561403/multipart-formdata-image-upload-get-the-file
See https://gist.github.com/1354221
See http://en.wikipedia.org/wiki/MIME

4.Popup 效果弹出视图
CGAffineTransform transform = CGAffineTransformIdentity;    ;      ;    } completion:^(BOOL finished) {      ;      } completion:^(BOOL finished) {            ;            } completion:^(BOOL finished) {                //do nothing            }];      }];    }];

5.上下摇晃动画效果
CALayer*viewLayer=;      CABasicAnimation*animation=;      animation.duration=0.1;      animation.repeatCount = 4;      animation.autoreverses=YES;      animation.fromValue=;      animation.toValue=;      ;

6.检查ARC的宏
#if !__has_feature(objc_arc)    ;#endif
页: [1]
查看完整版本: IOS 代码片段 (Update!)