我有一个桌面应用程序,它有一个C++后端和一个HTML5/JS前端.我们目前不得不使用Google V8或Mac Webview和Objective-C来允许Javascript和C++进行通信.有没有办法让他们在没有中间件的情况下直接相互交谈?
试图完成:
我试过谷歌搜索,一切都指向上述解决方案.
我正在尝试在Google Calendar API上执行简单的freebusy查询.我的授权一切工作正常,可以查看用户日历列表等.当我尝试提交忙/闲查询时,我得到400错误(据我所知)没有关于它的详细信息不喜欢.
在我自己的代码和使用Google Calendar API"试用"功能时都是如此.
这是我的请求(使用Try It小部件创建)和响应:Request
POST https://www.googleapis.com/calendar/v3/freeBusy?key={YOUR_API_KEY}
Content-Type: application/json
Authorization: Bearer ya29.AHES6ZTr-2wksEvp0iGPTnHTirTIItib5WwxmSAySq1ghfI98Cz88kA
X-JavaScript-User-Agent: Google APIs Explorer
{
"items": [
{
"id": "[my calendar id goes here]@group.calendar.google.com"
}
],
"timeMin": "2012-01-31T09:00:00",
"timeMax": "2012-01-31T10:00:00",
"timeZone": "GMT"
}
Response
400 Bad Request
cache-control: private, max-age=0
content-encoding: gzip
content-length: 122
content-type: application/json; charset=UTF-8
date: Sun, 16 Jun 2013 13:08:32 GMT
expires: Sun, 16 Jun 2013 13:08:32 GMT
server: GSE
{
"error": {
"errors": [
{
"domain": "global",
"reason": "badRequest",
"message": "Bad …Run Code Online (Sandbox Code Playgroud) 我在AppDelegate文件中使用Swift在我的应用程序中添加了CLLocationManager.
在Appdelegate.swift文件中,
import CoreLocation
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate {
var locationManager: CLLocationManager!
Run Code Online (Sandbox Code Playgroud)
在didbecomeActive方法中:
func applicationDidBecomeActive(application: UIApplication) {
if((locationManager) != nil)
{
locationManager.stopMonitoringSignificantLocationChanges()
locationManager.delegate = nil
locationManager = nil
}
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.activityType = CLActivityType.OtherNavigation
locationManager.requestAlwaysAuthorization()
locationManager.startMonitoringSignificantLocationChanges()
}
Run Code Online (Sandbox Code Playgroud)
如果我使用startUpdatingLocation,didUpdateLocations方法被调用,但不是startMonitoringSignificantLocationChanges.
为什么没有被要求startMonitoringSignificantLocationChanges.我在ios模拟器中测试这个.我不知道如何检查设备.
我在ios应用程序中使用drawpdf函数生成pdf,同时在nsobject类中调用drawtext函数,它根据我指定的框架和字符串清楚地绘制文本.
我的代码是
+(void)drawText:(NSString*)textToDraw inFrame:(CGRect)frameRect
{
CFStringRef stringRef = (__bridge CFStringRef)textToDraw;
// Prepare the text using a Core Text Framesetter
CFAttributedStringRef currentText = CFAttributedStringCreate(NULL, stringRef, NULL);
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(currentText);
CGMutablePathRef framePath = CGPathCreateMutable();
CGPathAddRect(framePath, NULL, frameRect);
// Get the frame that will do the rendering.
CFRange currentRange = CFRangeMake(0, 0);
CTFrameRef frameRef = CTFramesetterCreateFrame(framesetter, currentRange, framePath, NULL);
CGPathRelease(framePath);
// Get the graphics context.
CGContextRef currentContext = UIGraphicsGetCurrentContext();
// Put the text matrix into a known state. This ensures
// that …Run Code Online (Sandbox Code Playgroud) 我正在使用iOS 7解决状态栏问题
if(st.version == 7)
{
CGRect screen = [[UIScreen mainScreen] bounds];
CGRect frame = self.navigationController.view.frame;
frame.origin.y = 20;
frame.size.height = screen.size.height - 20;
self.navigationController.view.frame = frame;
}
Run Code Online (Sandbox Code Playgroud)
因为我正在使用导航控制器并使用导航控制器从一个推送到另一个[self.navigationController pushViewController:newone animated:YES];.它适用于所有视图控制器.但是,如果viewcontroller在xib中有mkmapview,则会出现ios 7的状态栏问题.
如果我删除mapview表单xib并推送到该视图控制器意味着,它就像是,

如果我通过下面的代码添加mapview,
mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 100, 320, 100)];
[self.view addSubview:self.mapView];
Run Code Online (Sandbox Code Playgroud)
看起来像,

怎么解决这个?
我正在使用以下代码使用 QLPreviewcontroller 在我的应用程序中显示一些文档,
let ql = QLPreviewController()
ql.dataSource = self
//ql.navigationItem.rightBarButtonItems = nil
ql.navigationItem.rightBarButtonItem = nil
presentViewController(ql, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
我不想要 QLPreviewcontroller 右上角的共享按钮。我试过设置rightBarButtonItem为零,但它不起作用。
我怎么能隐藏呢?
对于播放YouTube视频,我正在使用
-(void)playYoutubeVideo:(NSString *)youtubeUrl {
NSString *videoId = [self extractYoutubeIdFromLink:youtubeUrl];
NSLog(@"video Id %@",videoId);
[self playVideoWithId:videoId];
}
- (NSString *)extractYoutubeIdFromLink:(NSString *)link {
NSString *regexString = @"((?<=(v|V)/)|(?<=be/)|(?<=(\\?|\\&)v=)|(?<=embed/))([\\w-]++)";
NSRegularExpression *regExp = [NSRegularExpression regularExpressionWithPattern:regexString
options:NSRegularExpressionCaseInsensitive
error:nil];
NSArray *array = [regExp matchesInString:link options:0 range:NSMakeRange(0,link.length)];
if (array.count > 0) {
NSTextCheckingResult *result = array.firstObject;
return [link substringWithRange:result.range];
}
return nil;
}
- (void)playVideoWithId:(NSString *)videoId {
NSString *youTubeVideoHTML = @"<html><head><style>body{margin:0px 0px 0px 0px;}</style></head> <body> <div id=\"player\"></div> <script> var tag = document.createElement('script'); tag.src = 'http://www.youtube.com/player_api'; var firstScriptTag = document.getElementsByTagName('script')[0]; …Run Code Online (Sandbox Code Playgroud) 我正在使用UNUserNotificationCenterios 10.对于测试,我从当前时间开始设置本地通知10秒.
这是我试过的,
- (void)viewDidLoad {
[super viewDidLoad];
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert)
completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (!error) {
NSLog(@"request succeeded!");
[self set10Notifs];
}
}];
}
-(void) set10Notifs
{
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10.0")) {
#if XCODE_VERSION_GREATER_THAN_OR_EQUAL_TO_8
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
[calendar setTimeZone:[NSTimeZone localTimeZone]];
NSDateComponents *components = [calendar components:NSCalendarUnitTimeZone fromDate:[[NSDate date] dateByAddingTimeInterval:10]];
UNMutableNotificationContent *objNotificationContent = [[UNMutableNotificationContent alloc] init];
objNotificationContent.title = [NSString localizedUserNotificationStringForKey:@"Prayer!" arguments:nil];
objNotificationContent.body = [NSString localizedUserNotificationStringForKey:@"Time now"
arguments:nil]; …Run Code Online (Sandbox Code Playgroud) objective-c ios ios10 usernotifications unusernotificationcenter
我试图在http://developer.android.com/training/animation/screen-slide.html中实现一个android项目,我在一个类中有错误
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Intent;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.app.NavUtils;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
public class MainActivity extends FragmentActivity {
private static final int NUM_PAGES = 5;
private ViewPager mPager;
private PagerAdapter mPagerAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mPager = (ViewPager) findViewById(R.id.pager);
mPagerAdapter = new ScreenSlidePagerAdapter(getFragmentManager());
mPager.setAdapter(mPagerAdapter);
mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int …Run Code Online (Sandbox Code Playgroud)