小编Azi*_*ode的帖子

电子邮件进入收件箱后如何触发Google Apps脚本?

我创建了一个Google Apps脚本,用于检查电子邮件是否包含附件,然后将其发送到另一个电子邮件地址.

它工作正常,但我想创建一个触发器,一旦新电子邮件到达收件箱就会启动脚本.

我已经能够创建一个每小时启动脚本的触发器,但这不是我想要的

gmail google-apps-script

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

如何将圆角添加到UIBezierPath自定义矩形?

我设法创造圆角,但我遇到第一个圆角(右下角)的问题

题 :

  • 我可以在(moveToPoint)方法之前添加(addArcWithCenter)方法吗?
  • 如何摆脱矩形开头的直线(右下角)?

这是我的自定义矩形代码和截图:

let path = UIBezierPath()
path.moveToPoint(CGPoint(x: 300, y: 0))
path.addArcWithCenter(CGPoint(x: 300-10, y: 50), radius: 10 , startAngle: 0 , endAngle: CGFloat(M_PI/2)  , clockwise: true) //1st rounded corner
path.addArcWithCenter(CGPoint(x: 200, y: 50), radius:10, startAngle: CGFloat(2 * M_PI / 3), endAngle:CGFloat(M_PI) , clockwise: true)// 2rd rounded corner
path.addArcWithCenter(CGPoint(x: 200, y: 10), radius:10, startAngle: CGFloat(M_PI), endAngle:CGFloat(3 * M_PI / 2), clockwise: true)// 3rd rounded corner
// little triangle at the bottom
path.addLineToPoint(CGPoint(x:240 , y:0))
path.addLineToPoint(CGPoint(x: 245, y: -10)) …
Run Code Online (Sandbox Code Playgroud)

ios uibezierpath swift

14
推荐指数
3
解决办法
8127
查看次数

如何在反应组件的返回功能中使用IIFE?

当用户点击按钮时,我弹出一个模态页面,它运行正常:

render() {
  return (
     <div>
         <section>
             <button onClick={() => this.refs.simpleDialog.show()}>Open Modal</button>
         </section>
         <SkyLight hideOnOverlayClicked ref="simpleDialog" title="Test Modal">
             Text that appears inside the modal page
            <Button onClick={() => this.refs.simpleDialog.hide()} >Got It</Button>
         </SkyLight>
    </div>
)}
Run Code Online (Sandbox Code Playgroud)
  • 但我的目标是在用户第一次打开页面时自动打开模态.

  • 我不想通过单击按钮打开模态页面

问题:

  • 我可以使用IIFE(一个立即调用的函数表达式),以便在用户打开页面后立即打开模态吗?

  • 我的方法是将布尔值设置为true.如果值设置为true,则打开模态

用于模态的库:https: //github.com/marcio/react-skylight

javascript reactjs react-jsx

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

将我重定向到另一个 HTML 页面的可点击 div

我想点击 DIV(文章列1)(“这是一个矩形”)

它应该将我重定向到另一个 HTML 文档:

https://s3-us-west-1.amazonaws.com/example/the-example.html

块引用

<style>
    #content1 {
      width: 70%;
      overflow: auto;
      margin: 4% 0% 0% 23%;
      padding-left: 6%;
     }

    #content1 div {
      float: left;
      width:27%;
      height:20%;
      background-color: #efefef;
      margin: 1% 3% 2% 0%;
      padding: 2% 2% 1% 2%;
      text-align: center;
    }

   #content1 p {
      color:#f91d04;
    }

   .article-column1 {
      -moz-box-shadow: -5px 5px 29px #777777;
      -webkit-box-shadow: -5px 5px 29px #777777;
      box-shadow: -5px 5px 29px #777777;
      border-radius: 3px;
      -moz-border-radius: 3px;
      -webkit-border-radius: 3px;
      }

   .article-column2 {
       -moz-box-shadow: -5px 5px 29px #777777; …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery

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

是否可以像在(mapbox-gl-js文档中)一样使用react-map-gl添加GeoJSON行?

我正在尝试添加一条GeoJSON线以显示A点和B点之间的汽车方向(就像它们在mapbox-gl-js的官方文档中(https://www.mapbox.com/mapbox-gl- js / example / geojson-line /

但是react-map-gl的文档完全没有提及。

我如何使用https://uber.github.io/react-map-gl/#/Documentation/introduction/introduction实现类似的效果 :

到目前为止,这是我的代码:

class MapPage extends Component {
  constructor(props) {
    super(props);
     this.state = {
      viewport: {
       latitude: 38.63738602787579,
       longitude: -121.23576311149986,
       zoom: 6.8,
       bearing: 0,
       pitch: 0,
       dragPan: true,
       width: 600, 
       height: 600 
     }
    };
   }

render() {
  const { viewport } = this.state;

  return (
    <ReactMapGL
      {...viewport}
      mapboxApiAccessToken={MAPBOX_TOKEN}
      onViewportChange={newViewport => {
        this.setState({ viewport: newViewport });
      }}
    />
  );
 }
}
Run Code Online (Sandbox Code Playgroud)

屏幕截图2017年12月20日下午5 55 10

reactjs react-map-gl

6
推荐指数
2
解决办法
2049
查看次数

如何自定义UIDatePicker并更改文本颜色和背景颜色?

我在表格单元格中创建了日期对象的格式化显示,并使用UIDatePicker编辑这些值.

但我无法编辑文本的色调颜色和背景颜色.

第一个屏幕截图是实际不需要的结果:

实际的UIDatepicker

第二个屏幕截图是所需的结果:

在此输入图像描述

以下是该项目的链接:https://www.dropbox.com/sh/m74tnghpqeah8o7/AAA-rMlGe_mhqiuEkDhbApsUa?dl=0

uidatepicker uitableview ios swift

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

我收到一条警告,说当我模拟后台提取时从未调用完成处理程序

我按照所有步骤进行设置,background fetch但我怀疑performFetchWithCompletionHandler在 AppDelegate 中编写函数时犯了一个错误。

这是我在模拟后立即收到的警告 background fetch

Warning: Application delegate received call to -  application:
performFetchWithCompletionHandler:but the completion handler was never called.
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
    if let tabBarController = window?.rootViewController as? UITabBarController,
            viewControllers = tabBarController.viewControllers as [UIViewController]! {
      for viewController in viewControllers {
        if let notificationViewController = viewController as? NotificationsViewController {
         firstViewController.reloadData()
         completionHandler(.NewData)
         print("background fetch done")
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我如何测试它background-fetch是否有效?

ios swift background-fetch

5
推荐指数
1
解决办法
7935
查看次数

如何使用嵌套路由向页面添加内容而不使用react-router-v4删除以前路由的内容?

我正在使用react-router-v4官方文档中提供的侧边栏示例作为灵感https://reacttraining.com/react-router/web/example/sidebar

1-所以我的应用程序的初始URL将是: localhost:3000/search-page/Lists

2-我有一个可点击的链接列表,点击时会在侧边栏上显示点击的数据,当发生这种情况时,URL会更新: localhost:3000/search-page/Lists/itemList1selected

3-然后按"显示列表编号2"按钮显示新列表

4-当我点击"列表编号2"中的链接时,我的目标是使用嵌套路由.它会将其附加到从"列表编号1"中选择的项目下方...并同时更新URL:localhost:3000/search-page/Lists/itemList1selected/itemList2selected

这是我目前的代码:

class MyComponent extends Component {

  constructor(props) {
   super(props);
     this.state = {
      showListButtonPressed: true
     };
   this.showTheOtherList = this.ShowTheOtherList.bind(this);
  }

  showTheOtherList() {
   this.setState({
     showListButtonPressed: !this.state.showListButtonPressed
   });
  }

 render() {
   const dataList1 = dataFromDataBase
     .allItemsFromList1()
     .map(list1 => ({
       path: `${this.props.match.params.type}/${list1.id}`,
       mainList1: () => (
        <div>
          {`${list1.company}   ${list1.name}   ${list1.price}`}
        </div>
       ),
       sidebarList1: () => (
         <div>
           <h3>item List 1 selected</h3>
             {list1.company}
         </div>
       )
     }));

   const dataList2 = fakeFlightApiDataTesting
     .allItemsFromList2()
     .map(list2 => ({
       path: `${this.props.match.params.type}/${list2.id}`, …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-router-v4 react-router-dom

5
推荐指数
1
解决办法
272
查看次数

如何使用自定义布局跳转到UICollectionView中的任何单元格?

我的水平UICollectionView中有40个单元格和一个按钮.

当我点击按钮时,我可以从5号单元格跳转到10号单元格.

但是一旦我想要进一步的细胞(例如从5到25),

它不起作用,而是变为0.

码:

func setValue(value: Int, animated: Bool) {
   self.value = value
   if let row = find(values, value) {
   let indexPath = NSIndexPath(forRow: row, inSection: 0)
   selectedCell = collectionView.cellForItemAtIndexPath(indexPath) as? StepperCell
   collectionView.scrollToItemAtIndexPath(indexPath, atScrollPosition: .CenteredHorizontally, animated: animated)
  }
 }

override func prepareLayout() {
   let start = Int(collectionView!.bounds.size.width * 0.5) - statics.width / 2
   let length = collectionView!.numberOfItemsInSection(0)

if cache.isEmpty && length > 0 {
   for item in 0..<length {
     let indexPath = NSIndexPath(forItem: item, inSection: 0)
     let attributes = …
Run Code Online (Sandbox Code Playgroud)

ios uicollectionview swift

3
推荐指数
1
解决办法
1536
查看次数

如何在同一视图上交替使用平移手势和滑动手势?

我有一个包含计数器的视图.

我已经实现了两种不同的手势识别器,

UISwipeGesture将计数增加一,

和一个UIPanGesture,以便每次增加多个数字

用户刷卡的时间.

两种姿势都有效,但我的问题是它们不能同时工作.

我希望他们能够交替工作,例如,如果我做小滑动的话

计数器应该增加1,如果我继续向上拖动计数器

应该增加多个数字.

这是我的代码的一部分:

```

override func viewDidLoad() {
    super.viewDidLoad()

    setupSwipeGestures()
    setupPanGestures()
} 

private func setupSwipeGestures() {
    let swipeUp = UISwipeGestureRecognizer(target: self, action: Selector("handleSwipes:"))
    let swipeDown = UISwipeGestureRecognizer(target: self, action: Selector("handleSwipes:"))

    swipeUp.direction = .Up
    swipeDown.direction = .Down

    circleView.addGestureRecognizer(swipeUp)
    circleView.addGestureRecognizer(swipeDown)
}


private func setupPanGestures() {
    let panGesture = UIPanGestureRecognizer(target: self, action: Selector("handleThePan:"))
    circleView.addGestureRecognizer(panGesture)
}



extension UIPanGestureRecognizer {
    func isDown(circleView: UIView) -> Bool {
       let velocity : CGPoint = velocityInView(circleView)
         if velocity.y < 0 {
            print("ex …
Run Code Online (Sandbox Code Playgroud)

uigesturerecognizer ios uiswipegesturerecognizer uipangesturerecognizer swift

3
推荐指数
1
解决办法
6190
查看次数

如何对多个元素使用一个useRef?或者如何使用 useRef 来实现类似的行为?

我有多个按钮,单击时会触发不同的音频文件。

我设法使用useRef每个按钮不同的方式使其工作,但我想有更好的方法来实现这一点:

const App = () => {

  const myAudio1 = useRef()
  const myAudio2 = useRef()
  const myAudio3 = useRef()

  const handleAudio1 = () => {
    myAudio1.current.play()
  }

  const handleAudio2 = () => {
    myAudio2.current.play()
  }

  const handleAudio3 = () => {
    myAudio3.current.play()
  }

  return (
    <div id="drum-machine">
      <div onClick={() => handleAudio1()} id="Btn1">
        <div> Button 1
          <audio ref={myAudio1}>
            <source id="Btn1" src="drumSounds/sound1.wav" type="audio/mpeg"/>
          </audio>
        </div>
      </div>

      <div onClick={() => handleAudio2()} id="Btn2">
        <div> Button 2
          <audio ref={myAudio2}>
             <source id="Btn2" src="drumSounds/sound2.wav" …
Run Code Online (Sandbox Code Playgroud)

reactjs react-hooks

2
推荐指数
1
解决办法
6872
查看次数

按Apple Watch上的按钮时,更新iPhone上的标签

我正在构建一个应用程序来计算你有多少目标.

我想知道发送收集的数据的最佳方式是什么

Apple Watch to the iPhone(并在iPhone上显示)

大段引用

// Watchkit extension 

     var count = 1


  // a label
     @IBOutlet weak var goals: WKInterfaceLabel!

  // a button in the Apple Watch
     @IBAction func addCount() {

         goals.setText("\(count++)")
    }

  // IPhone View Controller
     @IBOutlet weak var yourTeamScore: UILabel!
Run Code Online (Sandbox Code Playgroud)
  • 我已经为扩展程序和Apple Watch设置了我的应用程序组.

  • 我应该使用NSUserDefaults将数据存储在扩展上,然后将其发送到iPhone应用程序(View Controller)吗?

  • 是否可以使用openParentApplication:回复以使用Apple Watch上收集的数据更新iPhone上的标签

watchkit

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