小编Azi*_*lah的帖子

Javascript与C++通信

我有一个桌面应用程序,它有一个C++后端和一个HTML5/JS前端.我们目前不得不使用Google V8或Mac Webview和Objective-C来允许Javascript和C++进行通信.有没有办法让他们在没有中间件的情况下直接相互交谈?

试图完成:

  1. 分享变量.
  2. 从C++调用函数到JS.
  3. 从JS到C++的调用函数.

我试过谷歌搜索,一切都指向上述解决方案.

javascript c++

8
推荐指数
2
解决办法
2万
查看次数

Google Calendar API 400错误

我正在尝试在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)

api google-calendar-api

8
推荐指数
1
解决办法
4181
查看次数

startMonitoringSignificantLocationChanges在swift中不起作用

我在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模拟器中测试这个.我不知道如何检查设备.

cllocationmanager ios ios-simulator swift location-services

8
推荐指数
1
解决办法
5362
查看次数

7
推荐指数
1
解决办法
4534
查看次数

iOS:如何在pdf生成中绘制文本时设置字体?

我在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)

iphone pdf-generation objective-c font-size ios

6
推荐指数
1
解决办法
4402
查看次数

添加MKMapView导致iOS 7中的状态栏问题

我正在使用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)

看起来像,

在此输入图像描述

怎么解决这个?

objective-c statusbar mkmapview ios ios7

6
推荐指数
1
解决办法
1126
查看次数

如何使用swift隐藏QLPreviewController中的共享按钮?

我正在使用以下代码使用 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为零,但它不起作用。

我怎么能隐藏呢?

rightbarbuttonitem ios qlpreviewcontroller swift

6
推荐指数
3
解决办法
8330
查看次数

有些YouTube视频无法在UIWebView中播放.显示 - (发生错误请稍后再试)

对于播放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)

youtube objective-c uiwebview ios

6
推荐指数
1
解决办法
820
查看次数

ios10中未触发本地通知

我正在使用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

6
推荐指数
1
解决办法
6160
查看次数

错误:构造函数MainActivity.ScreenSlidePagerAdapter(FragmentManager)未定义

我试图在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)

java android android-viewpager

5
推荐指数
2
解决办法
5959
查看次数