如果我想从NSString获取值@"value:hello World:value",我应该使用什么?
我想要的返回值是@"hello World".
我如何onBackPressed()在搜索模式下处理?我已经实现了搜索ActionBar,我想处理onBackPressed().
在MainActivity我加入了这一点,但它在搜索关闭仅获得通知
@Override
public void onBackPressed() {
mMenu.findItem(R.id.menu_eye).setVisible(true);
mMenu.findItem(R.id.menu_layers).setVisible(true);
super.onBackPressed();
};
Run Code Online (Sandbox Code Playgroud)
我的搜索动作监听器如下所示:
import com.cyrilmottier.polaris.PolarisMapView;
import android.app.SearchManager.OnCancelListener;
import android.content.Context;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.SearchView;
public class SearchListener implements SearchView.OnQueryTextListener, SearchView.OnCloseListener, SearchView.OnSuggestionListener, OnClickListener, OnCancelListener{
private Context mContext;
private PolarisMapView mMapView;
private Menu mMenu;
private SearchView mSearchView;
public SearchListener(Context c, PolarisMapView mMapView, Menu mMenu, SearchView mSearchView){
this.setmContext(c);
this.setmMapView(mMapView);
this.setmMenu(mMenu);
this.mSearchView = mSearchView;
}
@Override
public boolean onQueryTextChange(String newText) {
return false; …Run Code Online (Sandbox Code Playgroud) 我试图抓住一个手势,但它不起作用.这是我的代码:
UISwipeGestureRecognizer *recognizer;
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionRight | UISwipeGestureRecognizerDirectionLeft)];
[[self view] addGestureRecognizer:recognizer];
[recognizer release];
Run Code Online (Sandbox Code Playgroud)
和
-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {
NSLog(@"get gesture");
if (recognizer.direction == UISwipeGestureRecognizerDirectionRight) {
NSLog(@"get gesture right");
}
if (recognizer.direction == UISwipeGestureRecognizerDirectionLeft) {
NSLog(@"get gesture Left");
}
}
Run Code Online (Sandbox Code Playgroud)
它总是得到一个手势,但不认识方向.我也试过if(recognizer.direction){NSLog(@"get gesture");},它也有效,所以我不明白我犯了哪个错误.
谢谢你的帮助.
我已经实现了一个openCV应用程序,我使用SURF描述符.它工作正常,代码如下所示:
我减少输入视频流大小以加快速度
capture.set(Highgui.CV_CAP_PROP_FRAME_WIDTH, display.getWidth());
capture.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT, display.getHeight());
capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA);
try{
//-- Step 1: Detect the keypoints using SURF Detector
surfDetector.detect( mRgba, vector1 );
for (KeyPoint t : vector1)
Core.circle(mRgba, t.pt, 10, new Scalar(100, 100,100));
//-- Step 2: Calculate descriptors (feature vectors)
//extractor.compute(mRgba, vector1, descriptor1);
//-- Draw matches
//Mat img_matches;
//drawMatches( mRgba, vector1, mRgba, vector1, matches, img_matches );
}catch(Exception e){
Log.e( "ERROR", e.toString());
}
Run Code Online (Sandbox Code Playgroud)
但是计算仍然太慢,所以我需要找到另一种方法来减少输入视频流的质量.或者如果您知道另一种加速它的方法,请随时与我分享;)
谢谢你的时间和答案
就好奇而言,UIView类的nextResponder方法实现如何知道谁是管理视图的UIViewController?UIResponder文档说明了这一点,我可以看到它有效,但我不太明白.据我所知,UIView没有保持对它的控制器的引用,那么幕后发生了什么?或者我只是遗漏了一些明显的东西?
我对Objective-C和iPhone的开发还很新,所以如果这很明显,我很抱歉,但我很好奇.
谢谢!
如何向DialogFragment添加动画.我的动画是:
出于动画:
<scale
android:duration="200"
android:fillAfter="false"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="-90%"
android:startOffset="200"
android:toXScale="0.5"
android:toYScale="0.5" />
<translate
android:duration="300"
android:fromXDelta="0"
android:fromYDelta="0"
android:toXDelta="-200"
android:toYDelta="-200" />
Run Code Online (Sandbox Code Playgroud)
在动画中:
<scale
android:duration="200"
android:fillAfter="false"
android:fromXScale="0.5"
android:fromYScale="0.5"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="-90%"
android:toXScale="1.0"
android:toYScale="1.0" />
<translate
android:duration="300"
android:fromXDelta="-200"
android:fromYDelta="-200"
android:toXDelta="0"
android:toYDelta="0" />
Run Code Online (Sandbox Code Playgroud)
和我的代码:
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.setCustomAnimations(R.anim.jump_in, R.anim.jump_out, R.anim.jump_in, R.anim.jump_out);
ft.add(layer_frag, "layer frag");
ft.show(layer_frag).commit();//layer_frag is a class whitch extends DialogFragment
Run Code Online (Sandbox Code Playgroud)
我必须错过一些东西,因为它看起来像以前一样.
嗨我需要画一条路径简单的线条到画布它应该用白线写出红色矩形.但它不会画出什么mi缺失.我的代码:
Canvas canvas = new Canvas();
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.RED);
canvas.drawPaint(paint);
Path path = new Path();
//canvas.drawColor(Color.CYAN);
for (int i = 5; i < 50; i++) {
path.moveTo(4, i-1);
path.lineTo(4, i);
}
path.close();
paint.setStrokeWidth(3);
paint.setPathEffect(null);
paint.setColor(Color.WHITE);
paint.setStyle(Paint.Style.STROKE);
canvas.drawPath(path, paint);
for (int i = 0; i < 3; i++) {
View iview = inflater.inflate(R.layout.linear_layout, null);
if(i == 0){
iview.findViewById(R.id.imageView1).setBackgroundResource(R.drawable.distspeed);
}
if(i == 1){
iview.findViewById(R.id.imageView1).setBackgroundResource(R.drawable.hxmdist);
}
if(i == 2){
iview.findViewById(R.id.imageView1).setBackgroundResource(R.drawable.hxmspeeed);
}
iview.draw(canvas);
realViewSwitcher.addView(iview);
}
Run Code Online (Sandbox Code Playgroud) 嗨我有问题为我的Button设置多行,这是声明的:
button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.titleLabel.font = [UIFont systemFontOfSize: 12];
button.titleLabel.lineBreakMode = UILineBreakModeWordWrap;
button.titleLabel.numberOfLines = 0;
button.titleLabel.shadowOffset = CGSizeMake (1.0, 0.0);
[button addTarget:self
action:@selector(myButtonClick)
forControlEvents:UIControlEventTouchDown];
button.frame = CGRectMake(0.0, 100.0, 317.0, 100.0);
[button setTitle:string forState:UIControlStateNormal];
button.titleLabel.font = [UIFont systemFontOfSize: 12];
button.titleLabel.text = @"ahoj";
NSMutableString *ObratString = [[NSMutableString alloc] initWithString:button.titleLabel.text];
[ObratString appendString:@"\n"];
[ObratString appendString:@"caw"];
[ObratString appendString:@"\n"];
[ObratString appendString:@"helllo"];
button.titleLabel.text = ObratString;
[ObratString release];
[self.view addSubview:button];
Run Code Online (Sandbox Code Playgroud)
但最后我才看到第一行.有没有办法使它工作?
我正在尝试将facebook应用到我的iOS应用程序中用于学校项目但是我遇到了一些障碍,即没有调用fbDidLogin方法.
我创建了一个名为FBFetcher的示例对象,如下所示:
@interface FBFetcher : NSObject <FBDialogDelegate,FBSessionDelegate,FBRequestDelegate> {
Facebook *facebook;
FBFetcher *facebookFetcher;
}
-(void)login;
@property (retain) Facebook *facebook;
@property (retain) FBFetcher *facebookFetcher;
@end
Run Code Online (Sandbox Code Playgroud)
在FBFetcher.m中:
@implementation FBFetcher
@synthesize facebookFetcher,facebook;
-(void)login{
facebook = [[Facebook alloc] initWithAppId:@"...."];
NSArray *permissions = [[NSArray arrayWithObjects: @"offline_access",@"user_about_me", nil] retain];
[facebook authorize:permissions delegate:self];
}
-(void)fbDidLogin {
NSLog(@"Erfolgreich eingeloggt....");
}
@end
Run Code Online (Sandbox Code Playgroud)
在我的应用代表中:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [[[controller facebookFetcher] facebook] handleOpenURL:url];
}
Run Code Online (Sandbox Code Playgroud)
我有一个单独的视图控制器,其中n动作绑定到UIButton:
facebookFetcher = [[FBFetcher alloc] init];
[facebookFetcher login];
Run Code Online (Sandbox Code Playgroud)
我可以访问登录和授权页面,但fbDidLogin方法永远不会被调用.有什么建议?
嗨,我需要在iphone上使用嘟嘟声,但我发现的唯一一件就是这个
NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"alert" ofType:@"wav"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath: soundPath], &soundID);
AudioServicesPlaySystemSound (soundID);
[soundPath release];
Run Code Online (Sandbox Code Playgroud)
它是工作和良好的代码,但我需要导入alert.wav文件.但我宁愿做本机(内置)声音,如果存在.
谢谢你的所有答案cs.
objective-c ×5
android ×4
cocoa-touch ×4
ios ×2
iphone ×2
xcode ×2
animation ×1
beep ×1
facebook ×1
gesture ×1
nsstring ×1
opencv ×1
searchview ×1
uibutton ×1
uikit ×1