标题非常具有自我描述性.我已经下载了Qt Creator 2.7.0,我正在尝试编译一些基本的C++ 11代码:
int my_array[5] = {1, 2, 3, 4, 5};
for(int &x : my_array)
{
x *= 2;
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
range based for loops are not allowed in c++ 98 mode
Run Code Online (Sandbox Code Playgroud)
然而,根据这篇文章,这个版本的Qt Creator支持C++ 11.那么我该如何启用呢?
我是Android的新手.我已经花了两个小时搜索.无论我尝试使用软键盘都不会显示给我EditText.我简单地创建它:
EditText editText = (EditText)findViewById(R.id.editText);
Run Code Online (Sandbox Code Playgroud)
我试过了:
editText.requestFocus();//i tried without this line too
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
Run Code Online (Sandbox Code Playgroud)
和:
editText.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus)
{
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
}
});
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
Run Code Online (Sandbox Code Playgroud)
我试着将这一行放入AndroidManifest.xml文件中:
android:windowSoftInputMode="stateVisible|adjustResize"
Run Code Online (Sandbox Code Playgroud)
但一切都是徒劳的.它永远不会显示.我错过了什么?
我需要在我的应用程序中以编程方式打开设置.我搜遍了SO,但到处都有人说这是不可能的.但今天我看到它在Facebook应用程序中实现.有一个按钮UIAlertView,当你点击它时,你打开设置.所以确实可以打开设置,我亲眼目睹了这一点.但是怎么做呢?有谁知道Facebook如何做到这一点?
我已经阅读了苹果文档,这对于Objective-C像我这样的初学者来说是不可理解的.我正在尝试UITableView按照这个 链接示例实现多列,它只是不起作用所以我需要理解如何cellForRowAtIndexPath工作,因为我个人这个方法似乎相当复杂.
1)它返回什么?UITableViewCell?但为什么它看起来如此奇怪?
-(UITableViewCell *)tableView:(UITableView *)tableView
Run Code Online (Sandbox Code Playgroud)
2)如何调用它,更重要的是如何将它连接到某个UITableView??? 如果我有两个UITableView名字firstTableView并且secondTableView我希望它们不同(表现cellForRowAtIndexPath不同)怎么办?我UITableViews该如何将自己与此联系起来
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)
方法接受NSIndexPath,而不是UITableView.我该怎么办?
我希望你能帮助我,因为我不知道发生了什么.我在尝试将Beecrypt库添加到我的项目时遇到以下错误:
致命错误C1010:查找预编译头时意外结束文件.你忘了在你的来源添加'#include"stdafx.h"'吗?
其实我没有忘记将#include"stdafx"添加到我的源代码中.编译器将错误指向此.cxx文件的末尾:
#define BEECRYPT_CXX_DLL_EXPORT
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/c++/security/SecureRandom.h"
#include "beecrypt/c++/security/SecureRandomSpi.h"
#include "beecrypt/c++/security/Security.h"
using namespace beecrypt::security;
SecureRandom* SecureRandom::getInstance(const String& algorithm) throw (NoSuchAlgorithmException)
{
Security::spi* tmp = Security::getSpi(algorithm, "SecureRandom");
assert(dynamic_cast<SecureRandomSpi*>(tmp->cspi));
SecureRandom* result = new SecureRandom(reinterpret_cast<SecureRandomSpi*>(tmp->cspi), tmp->prov, tmp->name);
delete tmp;
return result;
}
SecureRandom* SecureRandom::getInstance(const String& type, const String& provider) throw (NoSuchAlgorithmException, NoSuchProviderException)
{
Security::spi* tmp = Security::getSpi(type, "SecureRandom", provider);
assert(dynamic_cast<SecureRandomSpi*>(tmp->cspi));
SecureRandom* result = new SecureRandom(reinterpret_cast<SecureRandomSpi*>(tmp->cspi), tmp->prov, tmp->name);
delete tmp;
return result;
}
SecureRandom* SecureRandom::getInstance(const String& type, const …Run Code Online (Sandbox Code Playgroud) c++ compiler-errors precompiled-headers visual-studio-2008 visual-c++
我有以下内容
我使用NIB(.xib文件)作为单元格,它使用CustomCell类.此自定义单元格类处理IBAction以触摸单元格的按钮.我想引用ViewController及其中的一些变量.我该怎么做(访问ViewController)?
谢谢!
我的IBOutlet NSLayoutConstraint应用程序中有一个.非常简单:
@property (nonatomic, weak) IBOutlet NSLayoutConstraint* leftConstraint;
Run Code Online (Sandbox Code Playgroud)
在某些时候,我想停用此约束:
self.leftConstraint.active = NO;
Run Code Online (Sandbox Code Playgroud)
它发生在一个名为from的方法中cellForRowAtIndexPath:.并且约束在上面的行之后变为零.但是,如果我声明这个属性,strong那么它没关系,它不会变为零.任何人都能解释为什么会这样吗?
这段代码:
bool contains = std::find(indexes.begin(), indexes.end(), i) != indexes.end();
CardAbility* cardAbility = contains ? new CardAbilityBurn(i) : new CardAbilityEmpty;
Run Code Online (Sandbox Code Playgroud)
给我以下错误:
不兼容的操作数类型CardAbilityBurn和CardAbilityEmpty
但是,如果我写这样的代码:
if (contains)
{
cardAbility = new CardAbilityBurn(i);
}
else
{
cardAbility = new CardAbilityEmpty;
}
Run Code Online (Sandbox Code Playgroud)
然后编译器不介意.为什么这样?我想使用三元条件运算符,因为它只是一行.那有什么不对?
我需要注意(我认为你可能需要这些信息)CardAbilityEmpty并且CardAbilityBurn两者都来源于CardAbility他们这么说兄弟.
谢谢
这里有什么不对:
#define CONTROLS_OFFSET 100
#ifdef CONTROLS_OFFSET//Unterminated conditional directive it says
#define FIND_MAIN_MENU 3
Run Code Online (Sandbox Code Playgroud)
为什么我会收到此错误?
这是我的问题.当我的应用程序进入后台时,我希望它在一段时间后执行一个功能.这就是我做的:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
isRunningInBackground = YES;
taskIdentifier = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:nil];
int64_t delayInSeconds = 30;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void)
{
[self doSomething];
});
}
- (void)doSomething
{
NSLog(@"HELLO");
}
Run Code Online (Sandbox Code Playgroud)
taskIdentifier 变量在myAppDelegate.h文件中声明如下:
UIBackgroundTaskIdentifier taskIdentifier;
Run Code Online (Sandbox Code Playgroud)
一切都按照预期的方式工作,我看到控制台在30秒后就打印了HELLO.但是doSomething如果应用程序进入前景直到30秒结束,我不想被执行.所以我需要取消它.这就是我这样做的方式:
- (void)applicationWillEnterForeground:(UIApplication *)application
{
isRunningInBackground = NO;
[self stopBackgroundExecution];
}
- (void)stopBackgroundExecution
{
[[UIApplication sharedApplication] endBackgroundTask:taskIdentifier];
taskIdentifier = UIBackgroundTaskInvalid;
}
Run Code Online (Sandbox Code Playgroud)
但不幸的是它没有取消doSomething,它仍然执行.我究竟做错了什么?如何取消该功能?
ios ×5
objective-c ×4
c++ ×3
cocoa-touch ×2
uikit ×2
uitableview ×2
android ×1
c++11 ×1
iboutlet ×1
keyboard ×1
qt ×1
swift ×1
visual-c++ ×1
xcode ×1