小编Riv*_*era的帖子

Express.js req.body undefined

我有这个作为我的Express服务器的配置

app.use(app.router); 
app.use(express.cookieParser());
app.use(express.session({ secret: "keyboard cat" }));
app.set('view engine', 'ejs');
app.set("view options", { layout: true });
//Handles post requests
app.use(express.bodyParser());
//Handles put requests
app.use(express.methodOverride());
Run Code Online (Sandbox Code Playgroud)

但是当我req.body.something在我的路线中要求时,我会得到一些错误指出body is undefined.以下是使用req.body以下路线的示例:

app.post('/admin', function(req, res){
    console.log(req.body.name);
});
Run Code Online (Sandbox Code Playgroud)

我读到这个问题是由于缺乏而引起的,app.use(express.bodyParser());但是你可以看到我在路线之前调用它.

任何线索?

node.js express

248
推荐指数
29
解决办法
26万
查看次数

在Windows上以全屏模式运行chrome

我想配置我的计算机以启动Google Chrome Windows启动.它应该以全屏模式启动并打开一些网页.

我尝试使用以下命令行运行Chrome:

chrome.exe --start-fullscreen --app=https://google.com
Run Code Online (Sandbox Code Playgroud)

但Chrome在窗口模式下打开,而不是在全屏模式下打开.

有没有办法在全屏模式下运行chrome?

google-chrome google-chrome-app

31
推荐指数
3
解决办法
18万
查看次数

昏暗的iPhone屏幕,但不要让它睡觉

更新

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIScreen_Class/index.html#//apple_ref/occ/instp/UIScreen/brightness

这是用于控制屏幕亮度的Apple Doc.以下是原始问题.


我发现使用Google可以通过以下方式禁用iPhone在应用程序中睡眠:

application.idleTimerDisabled = YES;
Run Code Online (Sandbox Code Playgroud)

所以代码看起来像这样:

- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    // Override point for customization after application launch

    // This disables the autosleep  I added this to TEST, 
    // delete later if you want:-
    application.idleTimerDisabled = YES;
    [window addSubview:switchViewController.view];
    [window makeKeyAndVisible];
Run Code Online (Sandbox Code Playgroud)

完美,效果很好.但是,我的问题是,我可以以某种方式禁止iPhone进入睡眠状态,同时仍然允许屏幕变暗吗?或者也许在应用程序中自己调暗屏幕以节省电池电量?

我绝对不希望iPhone睡觉,但我也希望用户友好/电池友好,并调暗屏幕.(你知道,就像你可以将iPhone设置为在睡眠前X秒调暗屏幕.)是否有一种有效的方法可以做到这一点?

iphone sleep objective-c

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

当用户按下搜索按钮时,UISeachBar会检测到

我尝试Search在键盘中单击按钮时收到通知UISearchBar:

    - (BOOL)textFieldShouldReturn:(UITextField *)textField{

        return YES;
    }
Run Code Online (Sandbox Code Playgroud)

但是当我按下"搜索"按钮时,此方法不会调用.

iphone objective-c uitextfield

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

在swift中对成员'joinWithSeparator'的模糊引用

我正在使用Google的' reverseGeocodeCoordinate'来获取基于纬度和经度的地址.
我在实现中遇到以下错误

对成员'joinWithSeparator'的模糊引用

以下是我的实施:

let aGMSGeocoder: GMSGeocoder = GMSGeocoder()
aGMSGeocoder.reverseGeocodeCoordinate(CLLocationCoordinate2DMake(17.45134626, 78.39304448)) {
    (let gmsReverseGeocodeResponse: GMSReverseGeocodeResponse!, let error: NSError!) -> Void in

    let gmsAddress: GMSAddress = gmsReverseGeocodeResponse.firstResult()
    print("lines=\(gmsAddress.lines)")
    let addressString = gmsAddress.lines.joinWithSeparator("")
    print("addressString=\(addressString)")

}
Run Code Online (Sandbox Code Playgroud)

我正在尝试addressString使用数组' gmsAddress.lines'中的元素创建一个,但最终会出现错误消息.

实施了一些示例代码片段来测试' joinWithSeparator'

let sampleArray = ["1", "2", "3", "4", "5"]
let joinedString = sampleArray.joinWithSeparator("")
print("joinedString=\(joinedString)")
Run Code Online (Sandbox Code Playgroud)

它成功了.
我观察到的是' sampleArray'是一个类型的元素数组String,但是' gmsAddress.lines'是' AnyObject' 类型的元素数组,在' GMSAddress'库中找到:

/** An array of NSString containing formatted lines of the address. …
Run Code Online (Sandbox Code Playgroud)

nsarray google-maps-sdk-ios swift ios9

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

检测片段中的滑动手势

嗨,我已经实现了一个Fragment,我想在我的片段上检测触摸事件.

但我无法检测到该事件,事实上,根本没有发现任何事件.它运作良好Activity,但它不是在片段上工作.

以下是我的代码:

  public class Swipe_Fragment extends Fragment implements
    GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {

private SimpleGestureFilter detector;
private LinearLayout swipLinear;
private static int DEFAULT = 50;
private int brightness;
private GestureDetectorCompat mDetector;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.swipe_screen, container,
            false);
    swipLinear = (LinearLayout) rootView.findViewById(R.id.swipLinear);

    brightness = DEFAULT;
    mDetector = new GestureDetectorCompat(getActivity(), this);
    // Set the gesture detector as the double tap
    // listener.
    mDetector.setOnDoubleTapListener(this);
    // Detect touched area
    // detector …
Run Code Online (Sandbox Code Playgroud)

android gesture android-fragments

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

Facebook SDK 4.5 IOS 9

我遇到了新的FBSDK问题.每当我尝试调用登录方法logInWithReadPermissions时,我收到以下错误消息:

错误:"canOpenUrl:url失败"fbauth2://"错误:"(null)"

我在dev.facebook上的ios9 tuto(https://developers.facebook.com/docs/ios/ios9)后面有我的配置.plist文件.所以,我得到了NSAppTransportSecurity字典和LSApplicationQueriesSchemes数组(上面有字符串"fbauth2")

你知道如何解决这个错误吗?

facebook ios facebook-ios-sdk ios9

16
推荐指数
2
解决办法
8257
查看次数

从base64编码的字符串中获取SecKeyRef

我正在开发一个iOS应用程序,我得到一个base64编码的公钥,例如:

MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3gn +口令是tJ1 + PbP0GHa6hmM35WsVyibpypWAwRuBYY4MGfh3VWoXgiyiLo5HJTW1eR9BUFq3z + yOG1rwzSabZ8I4zneWm0kH7xErSjNrMbmjirbL7e6TQNa1ujP/x4x9XVbqf3vIsNVs19kn/QSX/HGzd5Ct3TGAo0AT0T4JwkCfciwIDAQAB

我想用这个公钥编码一些文本,但我找不到将这个字符串转换为有用的公钥的方法.

我需要做什么?

security rsa ios

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

分配跟踪库没有及时加载,无法查看堆栈跟踪

在此输入图像描述要打开仪器,我们必须首先分析然后选择我们必须分析内存泄漏,分配,僵尸的模板.但是我仍然没有加载错误分配库,也无法看到堆栈跟踪.并且在应用程序中找不到泄漏的原因

正如其他链接中提到的解决方案,我正在使用模拟器(iOS7)和主动方案(iOS7)

Xcode版本:5.0.2版(5A3005)模拟器:iOS 7.0.3(111B508)Mac:OS X版本10.8.5

如果上述任何信息不正确,请原谅.请给出答案.谢谢

xcode profiling instruments ios

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

当changedValues为空时,NSManagedObject的hasChanges为true

我试图观察个别NSManagedObject变化NSManagedObjectContextWillSaveNotification:

- (void)managedObjectContextWillSave:(NSNotification *)notification
{
    for (NSManagedObject * object in self.mutableObservedManagedObjects)
    {
        if (object.hasChanges)
        {
            [self managedObjectWasUpdated:object];
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

问题是hasChanges当它object.changedValues是空的时候是真的,因此错误地(?)触发managedObjectWasUpdated:.

我试图理解为什么会这样,如果我object.changedValues.count在打电话之前应该更好地检查managedObjectWasUpdated:.


isInserted并且isDeleted都是假的.

macos core-data nsnotificationcenter ios

12
推荐指数
3
解决办法
2463
查看次数