#import <Foundation/Foundation.h> @interface SLSInAppPurchase : NSObject +(void)setInAppPurchase; +(BOOL)getInAppPurchase; @end
#import "SLSInAppPurchase.h" @implementation SLSInAppPurchase +(void)setInAppPurchase{ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setValue:[NSNumber numberWithBool:YES] forKey:@"key"]; [defaults synchronize]; } +(BOOL)getInAppPurchase{ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; return [defaults integerForKey:@"key"]; } @end
- (IBAction)reStoreA😔id)sender { [[SKPaymentQueue defaultQueue]restoreCompletedTransactions]; }
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue { NSLog(@"%@",queue ); NSLog(@"Restored Transactions are once again in Queue for purchasing %@",[queue transactions]); NSMutableArray *purchasedItemIDs = [[NSMutableArray alloc] init]; NSLog(@"received restored transactions: %lu", (unsigned long)queue.transactions.count); for (SKPaymentTransaction *transaction in queue.transactions) { NSString *productID = transaction.payment.productIdentifier; [purchasedItemIDs addObject:productID]; NSLog (@"product id is %@" , productID); [SLSInAppPurchase setInAppPurchase]; } }
NSThread.sleepforTimeInterval(3)
dispatch_async(dispatch_get_main_queue()){ self.labelStatus.text = "Done" }
dispatch_queue_t = dispatch_queue_create("tên kiểu",kiểu queue)
import MessageUI
MFMailComposeViewControllerDelegate {
var email:UITextField? var sdt:UITextField? var chuyenmuc: UITextField? var body:UITextView? override func viewDidLoad() { super.viewDidLoad() self.view.backgroundColor = UIColor.whiteColor() var centerPoint = CGPoint(x: self.view.bounds.size.width / 2, y: self.view.bounds.size.height / 2) self.email?.delegate = self // add email and sdt chuyen muc may tinh mac os cua tinh te email = UITextField(frame: CGRect(x: 20, y: 50, width: 300, height: 100)) email?.text = "tranmanhhoang@gmail.com" email?.textColor = UIColor.blueColor() email?.font = UIFont(name: "Verdana Bold.ttf", size: 18) email?.textAlignment = NSTextAlignment.Left self.view.addSubview(email!) sdt = UITextField(frame: CGRect(x: 20, y: 70, width: 300, height: 100)) sdt?.text = "0984230489" sdt?.font = UIFont(name: "Verdana Bold", size: 18) sdt?.textAlignment = NSTextAlignment.Left self.sdt?.delegate = self self.view.addSubview(sdt!) chuyenmuc = UITextField(frame: CGRect(x: 20, y: 90, width: 400, height: 100)) chuyenmuc?.text = "www.tinhte.vn/forums/mac-hoi-dap-cskn.27/" chuyenmuc?.textAlignment = NSTextAlignment.Left self.view.addSubview(chuyenmuc!) self.chuyenmuc?.delegate = self email?.userInteractionEnabled = true var guimail: UITapGestureRecognizer? guimail = UITapGestureRecognizer(target: self, action: "guiMail:") self.view.addGestureRecognizer(guimail!) // Do any additional setup after loading the view. } func guiMail(guimail: UITapGestureRecognizer) { var SubjectText = " Giúp MacOS! " // SubjectText += var mesaageBody = body var nguoinhan = ["tranmanhhoang@gmail.com"] var mc : MFMailComposeViewController = MFMailComposeViewController() mc.mailComposeDelegate = self mc.setSubject(SubjectText) mc.setMessageBody(mesaageBody?.text, isHTML: false) mc.setToRecipients(nguoinhan) // self.presentedViewController(mc , animated: true , completion: nil) self.presentViewController(mc, animated: true, completion: nil) } func mailComposeController(controller: MFMailComposeViewController!, didFinishWithResult result: MFMailComposeResult, error: NSError!) { switch result.value{ case MFMailComposeResultCancelled.value: NSLog("Mail cancel") case MFMailComposeResultFailed.value: NSLog("Mail fail : %@",[error.localizedDescription]) case MFMailComposeResultSaved.value: NSLog("Maiil Save") case MFMailComposeResultSent.value: NSLog("Mail sent") default: break } self.dismissViewControllerAnimated(true, completion: nil) } func textFieldShouldBeginEditing(textField: UITextField) -> Bool { return false }
sdt?.userInteractionEnabled = true let callHoang = UITapGestureRecognizer(target: self, action: "calHoang:") sdt?.addGestureRecognizer(callHoang) func calHoang(tap: UITapGestureRecognizer) { var url = NSURL(string: "tel:0984230489") UIApplication.sharedApplication().openURL(url!) }
chuyenmuc?.userInteractionEnabled = true let voTinhte = UITapGestureRecognizer(target: self, action: "voTinhte:") chuyenmuc?.addGestureRecognizer(voTinhte) func voTinhte(votinhte: UITapGestureRecognizer){ var url = NSURL(string: "http://www.tinhte.vn/forums/mac-hoi-dap-cskn.27/") UIApplication.sharedApplication().openURL(url!) }
var back : UIBarButtonItem = UIBarButtonItem(title: "Quay lại", style: UIBarButtonItemStyle.Plain, target: self, action: "backview") if let font = UIFont(name: "Chalkboard", size: 16) { back.setTitleTextAttributes([NSFontAttributeName: font], forState: UIControlState.Normal) } self.navigationItem.leftBarButtonItem = back func backview() { if let navController = self.navigationController { navController.popViewControllerAnimated(true) } }
url = NSURL(string: "http://mmovie.hdviet.com/tim-kiem-theo-loai.html?key=\(searchBar.text)&&page=\(currentPage)")
var timkiem = "http://mmovie.hdviet.com/tim-kiem-theo-loai.html?key=" timkiem += searchBar.text url = NSURL(string: timkiem.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!)
func giam1may(sender: UILongPressGestureRecognizer) { if (sender.state == UIGestureRecognizerState.Ended){ } if (sender.state == UIGestureRecognizerState.Began) { t -= 1 NSUserDefaults.standardUserDefaults().setInteger(t, forKey: "somaymac") NSUserDefaults.standardUserDefaults().synchronize() NSLog("giam 1 may") hienthisomaycon() }
func toggleTorch() { let avDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo) // check if the device has torch if avDevice.hasTorch { // lock your device for configuration avDevice.lockForConfiguration(nil) // check if your torchMode is on or off. If on turns it off otherwise turns it on avDevice.torchMode = avDevice.torchActive ? AVCaptureTorchMode.Off : AVCaptureTorchMode.On // sets the torch intensity to 100% avDevice.setTorchModeOnWithLevel(1.0, error: nil) // unlock your device avDevice.unlockForConfiguration() } }
func toggleTorchOff() { let device = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo) if (device.hasTorch) { device.lockForConfiguration(nil) let torchOn = !device.torchActive device.setTorchModeOnWithLevel(1.0, error: nil) device.torchMode = torchOn ? AVCaptureTorchMode.On : AVCaptureTorchMode.Off device.unlockForConfiguration() } }
func checkNet() { AFNetworkReachabilityManager.sharedManager().startMonitoring() AFNetworkReachabilityManager.sharedManager().setReachabilityStatusChangeBlock { (status:AFNetworkReachabilityStatus) -> Void in switch status.hashValue{ case AFNetworkReachabilityStatus.NotReachable.hashValue: NSLog("Not reachable") case AFNetworkReachabilityStatus.ReachableViaWiFi.hashValue , AFNetworkReachabilityStatus.ReachableViaWWAN.hashValue : NSLog("Reachable") default: NSLog("Unknown status") }} }
func setupGestureRecognizer() { let dismissKeyboardTap = UITapGestureRecognizer(target: self, action: "dismissKeyboard") dismissKeyboardTap.cancelsTouchesInView = false self.navigationController?.navigationBar.addGestureRecognizer(dismissKeyboardTap) } func setupGestureRecognizer2() { let dismissKeyboardTap = UITapGestureRecognizer(target: self, action: "dismissKeyboard") dismissKeyboardTap.cancelsTouchesInView = false self.view.addGestureRecognizer(dismissKeyboardTap) } func dismissKeyboard() { self.view.endEditing(true) }
UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyBoard)]; [self.view addGestureRecognizer:tapGesture]; -(void)hideKeyBoard { [_titleTextField resignFirstResponder]; [_contentTextView resignFirstResponder]; }
Bài mới