在GitHub我有一个简单的iPhone应用程序,它从社交网络Mail.ru获取用户信息(通过使用OAuth):

它确实获取并打印信息,但随后崩溃.
作为一个iOS编程新手,我对下面的输出感到困惑(也请看看PasteBin的完整输出):
2014-01-21 21:21:10.873 oauthMailru[8228:3307] -[__NSArrayM objectForKeyedSubscript:]: unrecognized selector sent to instance 0x8a97290
2014-01-21 21:21:10.875 oauthMailru[8228:3307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM objectForKeyedSubscript:]: unrecognized selector sent to instance 0x8a97290'
*** First throw call stack:
(
0 CoreFoundation 0x01aa65e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x018298b6 objc_exception_throw + 44
2 CoreFoundation 0x01b43903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01a9690b ___forwarding___ + 1019
4 CoreFoundation 0x01a964ee _CF_forwarding_prep_0 + 14
5 oauthMailru 0x00003a62 __47-[ViewController fetchMailruWithToken:ForUser:]_block_invoke …Run Code Online (Sandbox Code Playgroud) 在iPhone文字游戏中,我有一个UIScrollView(持有UIImageView)和7个可拖动的自定义UIViews,最初放在底部(滚动视图外):

在单个ViewController.m中,我已经覆盖了viewDidLayoutSubviews所以它总是设置zoomScale滚动视图 - 使UIImageView填充恰好100%的屏幕宽度.
这适用于纵向和横向模式.当应用程序刚刚启动时:


但问题是,当我第一次捏合/缩放/双击滚动视图然后移动七个Tile.m视图中的一个时:
突然(不是每次)都viewDidLayoutSubviews被称为touchesBegan.
这会重置滚动视图的缩放 - 意外地为用户.
我的问题是,是否有任何方法可以禁用此行为?
viewDidLayoutSubviews当孩子UIView被触摸/拖动时,是否可以阻止父母的呼叫?
更新:
我已经将zoomScale设置代码移动viewDidLayoutSubviews到didRotateFromInterfaceOrientation了,滚动视图缩放现在可以了,但它contentOffset被重置为{0,0},当(不总是)我拖动Tile时 - 即滚动视图突然跳跃,应用程序无法使用.
添加以下内容viewDidLoad没有帮助:
if ([self respondsToSelector:@selector(setAutomaticallyAdjustsScrollViewInsets:)])
self.automaticallyAdjustsScrollViewInsets = NO;
Run Code Online (Sandbox Code Playgroud) 我有一个无效的plsql函数:
CREATE OR REPLACE FUNCTION do_something(p_id BIGINT)
RETURNS void
AS $$
BEGIN
insert ....
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;
Run Code Online (Sandbox Code Playgroud)
我想从另一个plsql函数中调用此函数,但是要在一个查询中进行如下操作:
SELECT do_something(m.id)
FROM MyTable m
WHERE m.IsActive;
Run Code Online (Sandbox Code Playgroud)
当我运行时,sproc我得到:
错误:查询没有结果数据的目的地提示:如果要舍弃SELECT的结果,请改用PERFORM。
是否可以将void函数作为select语句的一部分来调用?
我需要在flex中匹配EOF
这是我的代码lex.l的主要错误部分
%{
%}
%%
<<EOF>> {printf("match EOF\n");}
%%
int main(){
yylex();
}
Run Code Online (Sandbox Code Playgroud)
我用
flex lex.l ; gcc lex.yy.c -o lex.exe -lfl ; lex.exe < text
Run Code Online (Sandbox Code Playgroud)
执行
这是我的文本文件只有一行
abc(no \n or \r at the end of file)
Run Code Online (Sandbox Code Playgroud)
但是当我执行lex.exe时,它进入无限循环并输出无限行"匹配EOF \n"
如何解决问题?
在一个简单的PHP 脚本(一个 WordPress 模块)中,我定义了一个包含几个静态方法的类:
class WP_City_Gender {
public static function valid($str) {
return (isset($str) && strlen($str) > 0);
}
public static function fix($str) {
return (WP_City_Gender::valid($str) ? $str : '');
}
public static function user_register($user_id) {
if (WP_City_Gender::valid($_POST[FIRST_NAME]))
update_user_meta($user_id, FIRST_NAME, $_POST[FIRST_NAME]);
if (WP_City_Gender::valid($_POST[LAST_NAME]))
update_user_meta($user_id, LAST_NAME, $_POST[LAST_NAME]);
if (WP_City_Gender::valid($_POST[GENDER]))
update_user_meta($user_id, GENDER, $_POST[GENDER]);
if (WP_City_Gender::valid($_POST[CITY]))
update_user_meta($user_id, CITY, $_POST[CITY]);
}
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,我必须将字符串添加WP_City_Gender::到所有静态方法名称之前 - 即使我从静态方法调用它们也是如此。
否则我会收到编译错误:
PHP 致命错误:调用未定义的函数 valid()
这对我来说似乎不寻常,因为在其他编程语言中,可以在不指定类名的情况下从静态方法调用静态方法。
这里有没有更好的方法(在 CentOS 6 上使用 PHP 5.3),使我的源代码更具可读性?
我目前正在开发一个 Flex/bison 项目。
我需要在一次执行中解析多个文件,因此我创建了一个循环来多次运行 YYPARSE() 。
当 flex 发现词汇或语法错误时,文件的解析会停止,程序会开始解析下一个文件。但是,该新文件的解析并不是从头开始。事实上,如果文件 3 的解析在第 8 行停止,解析将从文件 4 的第 8 行开始。
我该如何解决这个问题?
提前致谢。
这是我的 bison.y 文件中的主要函数:
int main(int argc, char* argv[]){
DIR* dir;
struct dirent *ent;
int val = 0;
if ((dir = opendir ("../TpCompileHoho")) != NULL)
{
// print all the files and directories within directory
while ((ent = readdir (dir)) != NULL)
{
if ((strcmp(ent->d_name,".") != 0) && (strcmp(ent->d_name,"..") != 0) && (strstr(ent->d_name,".txt") != NULL))
{
yyin = fopen(ent->d_name,"r");
yyparse();
}
} …Run Code Online (Sandbox Code Playgroud) 我有关于从资源加载Bitmap的问题.我的代码:
public void onClick(View view) {
if (mainButton == view) {
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.test);
}
}
Run Code Online (Sandbox Code Playgroud)
test.jpg图像分辨率为3288 x 4936px.它是jpeg(未压缩时为3,9MB/48,7MB).虽然此功能有效(在我的Nexus 7 2013设备上),但会发生以下异常:
java.lang.OutOfMemoryError: Failed to allocate a 259673100 byte allocation with 5222644 free bytes and 184MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:467)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:497)
at pl.jaskol.androidtest.MainActivity.onClick(MainActivity.java:50)
at android.view.View.performClick(View.java:4756)
at android.view.View$PerformClick.run(View.java:19749)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Run Code Online (Sandbox Code Playgroud)
为什么应用程序尝试分配多达248MB?我在Qt for Android中编写了类似的应用程序,在资源中使用相同的图像并且工作正常.
编辑: …
在与蓝牙相关的应用程序(带有minSdkVersion="18")中,我有一个MainActivity.java,显示以下 3 个 UI 片段之一:

要显示“向上按钮”并处理“后退按钮”,我有以下代码:
public class MainActivity extends Activity
implements BleWrapperUiCallbacks {
// set in onResume() of each fragment
private Fragment mActiveFragment = null;
´ @Override
public void onBackPressed() {
if (!getFragmentManager().popBackStackImmediate())
super.onBackPressed();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_ACTION_BAR);
setContentView(R.layout.activity_root);
getActionBar().setDisplayHomeAsUpEnabled(true);
if (savedInstanceState == null) {
Fragment fragment = new MainFragment();
getFragmentManager().beginTransaction()
.replace(R.id.root, fragment, "main")
.commit();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch …Run Code Online (Sandbox Code Playgroud) android android-fragments android-actionbar up-button android-navigation
npm installnpm install这里:
npm ERR! install **Couldn't read dependencies**
npm ERR! Darwin 14.0.0
npm ERR! argv "node" "/usr/local/bin/npm" "install"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! path /Users/Raj/package.json
npm ERR! code ENOPACKAGEJSON
npm ERR! errno -2
npm ERR! package.json ENOENT, open '/Users/Raj/package.json'
npm ERR! package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm can't find a package.json file in your current directory. …Run Code Online (Sandbox Code Playgroud) android ×3
flex-lexer ×2
ios ×2
bison ×1
bitmap ×1
eof ×1
git ×1
image ×1
iphone ×1
java ×1
javascript ×1
lex ×1
macos ×1
match ×1
memory ×1
node.js ×1
npm ×1
objective-c ×1
parsing ×1
php ×1
php-5.3 ×1
plpgsql ×1
postgresql ×1
regex ×1
textview ×1
touchesbegan ×1
uiimageview ×1
uiscrollview ×1
up-button ×1
wordpress ×1