小编ipa*_*tch的帖子

如何解码/转换base64字符串到NSData?

您好我正在试图弄清楚如何将iOS应用程序中的base64字符串转换/解码为NSData,因此我可以解密我加密的数据.

我可以在这里找到用于将NSData 转换为base 64字符串的方法.有没有类似的方法来创建解码/转换base 64字符串到NSData的方法?

xcode base64 nsstring ios

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

使用D3.js动画圆圈

所以我现在已经和D3.js搞乱了几天而且我有基本的圆圈生成/动画(充当气泡),我想知道如何在x axsis上为圆圈设置动画,让它们摆动回来作为旅行/过渡到页面顶部.可以在chrisrjones.com/bubbles-v1.html查看当前动画

javascript animation d3.js

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

HTML5 CSS页面正在内容的中间加载,不是所希望的

我一直在使用CSS编写一个HTML5页面,一切似乎进展顺利,但是页面没有使用Firefox 23加载到顶部.当我在Chrome中加载页面时,它似乎跳到了与Firefox相同的位置加载,但然后将页面跳到顶部.

这是使用Firefox 23在初始加载时加载页面的地方.

该页面可以在互联网上找到,http://ipatch.github.io/KegCop/

更新:我刚刚加载了没有样式表的HTML页面,看起来它仍在加载不需要的行为.

在此输入图像描述

html css firefox html5 css3

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

CBCentralManager连接到CBPeripheralManager,连接然后断开连接?

我有一个iOS设备(iPod Touch 5G)充当CBCentralManager,而Bluno充当CBPeripheralManager.当我尝试连接到中心的外围设备时,它似乎连接一两秒然后断开连接.我可以看到Bluno上的LED点亮一两秒然后变暗.我知道Bluno没有问题,因为我可以使用iPod Touch上的LightBlue应用程序连接到外围设备.所以这个问题可能就在我的代码中.

截至目前,我在状态syslog时收到以下消息:

CoreBluetooth[WARNING] <CBCentralManager: 0x16e77470> is disabling duplicate filtering, but is using the default queue (main thread) for delegate events
Run Code Online (Sandbox Code Playgroud)

不确定这是否与连接/断开问题有关.

我构建的代码如下,

Services.h

#define BLUNO_TRANSFER_SERVICE_UUID         @"0xDFB0"
#define BLUNO_TRANSFER_CHARACTERISTIC_UUID  @"0xDFB2"
Run Code Online (Sandbox Code Playgroud)

ViewControllerDev2.h

#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import <QuartzCore/QuartzCore.h>

#import "SERVICES.h"

@interface ViewControllerDev2 : UIViewController <CBCentralManagerDelegate, CBPeripheralDelegate, UITextViewDelegate> {


}

@property (weak, nonatomic) IBOutlet UIBarButtonItem *btnDone;

// Core Bluetooth Peripheral stuff
@property (strong, nonatomic) CBCentralManager *centralManager;
@property (strong, nonatomic) CBPeripheral *discoveredPeripheral;
@property (strong, nonatomic) NSMutableData *data;



@property (strong, nonatomic) IBOutlet …
Run Code Online (Sandbox Code Playgroud)

c objective-c ios core-bluetooth

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

使用导轨4单击按钮时显示确认对话框?

我正在使用rails 4.x项目,当用户单击项目中的按钮时,我想显示一个确认对话框.我创建了一个注册表单,并有一个注册按钮但是当我有以下代码时,

<%= f.submit "Sign Upp", class: 'btn btn-xlarge btn-custom', confirm: "test", method: :create %>

永远不会出现确认对话框.我确信我有一个create在控制器中命名的方法,但我似乎无法解决这个问题.如果它有所作为,(不确定是否有,我在项目中使用twitter bootstrap gem.)

javascript ruby-on-rails twitter-bootstrap ruby-on-rails-4

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

如何使用自动布局在屏幕中水平和垂直居中UILabel?

我一直在使用汽车布局几天,我试图将UILabel垂直和水平地放在屏幕中,但是我没有太多运气让标签居中.

我希望能够实现如下所示的东西,

  ---------------
 |               |
 |               |
 |               |
 |               |
 |    Label      |
 |               |
 |               |
 |               |
 |               |
 | SIGNIN   REG  |
  ---------------
Run Code Online (Sandbox Code Playgroud)

我向UILabel添加了以下约束,

NSLayoutConstraint *myLabelConstraintHeight = [NSLayoutConstraint constraintWithItem:myLabel
                                                                          attribute:NSLayoutAttributeHeight
                                                                          relatedBy:NSLayoutRelationEqual toItem:nil
                                                                          attribute:NSLayoutAttributeNotAnAttribute
                                                                         multiplier:1.0f
                                                                           constant:100];

            [myLabel addConstraint:myLabelConstraintHeight];


            NSLayoutConstraint *myLabelConstraintWidth = [NSLayoutConstraint constraintWithItem:myLabel
                                                                                      attribute:NSLayoutAttributeWidth
                                                                                      relatedBy:NSLayoutRelationEqual toItem:nil
                                                                                      attribute:NSLayoutAttributeNotAnAttribute
                                                                                     multiplier:1.0f
                                                                                       constant:100];
            [myLabel addConstraint:myLabelConstraintWidth];
Run Code Online (Sandbox Code Playgroud)

objective-c ios autolayout

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

在视图控制器之间传递数据 - iOS Xcode - 有什么好办法?

好吧,我会尝试尽可能简单(当我试着问这个问题时,我好像在chat.stackoveflow.com上跑来跑去).我想将文本从一个viewcontroller中的textfield传递给另一个viewcontroller.

我应该使用Model类并将textfield.text存储在Model.[h/m]文件中,然后让第二个视图控制器访问存储在模型中的数据吗?

基本上这就是我所拥有的,

ViewControllerWelcome.h

@interface ViewControllerWelcome : UIViewController { }

@property (weak, nonatomic) IBOutlet UITextField *textFieldUsername;
Run Code Online (Sandbox Code Playgroud)

ViewControllerWelcome.m

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
                ViewControllerHome *home = (ViewControllerHome *)[storyboard instantiateViewControllerWithIdentifier:@"Home"];
                NSString *username = _textFieldUsername.text;
                home.lblUSERNAME.text=username;
                [self presentModalViewController:home animated:YES];
Run Code Online (Sandbox Code Playgroud)

ViewControllerHome.h

@interface ViewControllerHome : UIViewController {
NSString *username;
UILabel *lblUSERNAME;
}

@property (weak, nonatomic) IBOutlet UILabel *lblUSERNAME;
Run Code Online (Sandbox Code Playgroud)

ViewControllerHome.m

- (void)changeUSERNAME {

 // get username from welcome tf
ViewControllerWelcome *welcome = [[ViewControllerWelcome alloc] init];
 welcome.username = [self lblUSERNAME.text];
 // _lblUSERNAME.text = welcome._textFieldUsername.text; …
Run Code Online (Sandbox Code Playgroud)

xcode textfield nsstring ios

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

VM892:1 未捕获语法错误:JSON 中位置 0 处出现意外标记 e

我目前正在开发用 Elixir 编写的 phx / phoenix API。我使用 React.js 创建了一个 API 前端。但是,我在浏览器的 JS 控制台中收到以下错误消息。

我已经使用 Postman 成功创建了一个用户,所以我 99% 确定错误不是与 phx 项目有关,而是与 React 项目有关。

我的前端后端都托管在 github 上。.env需要在 React 项目的根目录中创建一个文件,其中包含以下行:

REACT_APP_API_URL=http://localhost:4000/api
Run Code Online (Sandbox Code Playgroud)

并正在按照以下教程进行工作。

任何和所有的帮助将不胜感激。

错误信息

json elixir reactjs phoenix-framework

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

Xcode编译错误 - ld:找不到架构armv7的符号

我最近添加了文件Serial.cSerial.h我的Xcode项目.

代码Serial.c如下,

#include <stdio.h>   /* Standard input/output definitions */
#include <stdlib.h>
#include <string.h>  /* String function definitions */
#include <unistd.h>  /* UNIX standard function definitions */
#include <fcntl.h>   /* File control definitions */
#include <errno.h>   /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */

/*
* 'open_port()' - Open serial port on dock connector pins 13RX / 12TX
*
* Returns the file descriptor on success or -1 on error. …
Run Code Online (Sandbox Code Playgroud)

xcode symbols serial-port

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

试图用grep从plist中提取一个数字

我会尝试简短地提出这个问题.基本上,我正在开发一个shell脚本,我有一个包含整数值的.plist文件,我试图"提取"并将其放入我的shell脚本中的变量中.

我能够将.plist文件的内容细化为几行,但我仍然得到一堆我不需要的字符.

我正在我的shell脚本中修改/运行以下命令,它给了我以下结果.

  file_refine=`grep -C 2 CFBundleVersion $file | grep '[0-9]\{3\}'`
Run Code Online (Sandbox Code Playgroud)

产量

  <string>645</string>
Run Code Online (Sandbox Code Playgroud)

我只需要数字数字而不是字符串标签,但我似乎无法弄明白.

bash grep

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

Obj-C - 如何使用单例在viewcontrollers之间传递数据?

好吧,这是我昨晚问的问题的延伸.我对如何使用各种技术在视图控制器之间传递数据有一点了解.我想进入MVC路线,创建一个Singleton类似乎是最接近MVC的概念.

基本上我用两个View Controllers和一个singleton类创建了一个简单的应用程序.我试图将文本字段的值传递给UILabel.无论出于何种原因它都无法正常工作 这就是我的代码.

ViewController.h

#import <UIKit/UIKit.h>
#import "Model.h"
#import "ViewController2.h"

@interface ViewController : UIViewController {

NSString *text2pass;
}

@property (weak, nonatomic) IBOutlet UITextField *tf;
@property (weak, nonatomic) IBOutlet UILabel *btn;
- (IBAction)go:(id)sender;
@end
Run Code Online (Sandbox Code Playgroud)

ViewController.m

 #import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize tf = _tf;
@synthesize btn = _btn;

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

NSString *tfstring = _tf.text;
NSLog(@"string = %@",tfstring);
}

 - (void)viewDidUnload
{ …
Run Code Online (Sandbox Code Playgroud)

xcode ios

-10
推荐指数
1
解决办法
5640
查看次数