我有CLLocation对象,其中包含用户的当前位置,我有一个矩形的每个角可以成角度的4个纬度/长对.现在我想检查CLLocation坐标是否在该矩形内.
以下是矩形的坐标
#define NorthEast_LAT 51.514894
#define NorthEast_LNG -0.135306
#define SouthEast_LAT 51.514831
#define SouthEast_LNG -0.135153
#define NorthWest_LAT 51.514719
#define NorthWest_LNG -0.135858
#define SouthWest_LAT 51.514556
#define SouthWest_LNG -0.135714
Run Code Online (Sandbox Code Playgroud)
我尝试过以下代码,但我认为它只适用于矩形角度为0度的情况.
BOOL withinRect = [delegate.CLController latlngWithInBox:location
point1:CLLocationCoordinate2DMake(NorthEast_LAT, NorthEast_LNG)
point2:CLLocationCoordinate2DMake(SouthEast_LAT, SouthEast_LNG)
point3:CLLocationCoordinate2DMake(NorthWest_LAT, NorthWest_LNG)
point4:CLLocationCoordinate2DMake(SouthWest_LAT, SouthWest_LNG)];
- (BOOL) latlngWithInBox:(CLLocation *)position point1:(CLLocationCoordinate2D)point1 point2:(CLLocationCoordinate2D)point2 point3:(CLLocationCoordinate2D)point3 point4:(CLLocationCoordinate2D)point4 {
if (position.coordinate.latitude >= point3.latitude && position.coordinate.latitude <= point2.latitude
&& position.coordinate.longitude >= point3.longitude && position.coordinate.longitude <= point2.longitude) {
return YES;
}
return NO;
Run Code Online (Sandbox Code Playgroud)
}
我正在尝试在我的应用程序中加载大小为495KB的图像.如果我加载此图像比堆大小从25MB增加到35MB,这导致我的应用程序中出现真正的内存问题.如果我不加载此图像比堆大小保持在25MB.任何人都可以告诉它为什么需要这么多的堆大小?
图片如下

我用来加载图片的代码是
InputStream s4 = getResources().openRawResource(R.drawable.parallax_layer4);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
System.gc();
if(bitmap4 != null) {
bitmap4.recycle();
}
s3 = null;
System.gc();
bitmap4 = bitmap(s4);
layer4Back = new ImageView(this);
layer4Back.setImageBitmap(bitmap4);
layer4Back.setScaleType(ScaleType.FIT_XY);
parallaxLayout.addView(layer4Back, 3, lp);
try {
s4.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
s4 = null;
System.gc();
private static Bitmap bitmap(final InputStream is) {
Bitmap bitmap = null;
System.gc();
Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.RGB_565;
options.inSampleSize = 1;
try { …Run Code Online (Sandbox Code Playgroud) 我在我的网址中有超过9个参数被映射到特定的php文件.网址是
我的htaccess规则是
RewriteRule ^ USA /([^ /] +)/([^ /] +)/([^ /] +)/([^ /] +)/([^ /] +)/([^ /] + )/([^ /] +)/([^ /] +)/([^ /] +)/([^ /] +)/?$ search.php?counrty = USA&state = $ 1&gender = $ 2&r_city = $ 3&r_mstatus = $ 4&r_religion = $ 5&r_ethnicity = $ 6&r_cast = $ 7&r_profession = $ 8&r_education = $ 9&sort_by = $ 10 [NC]
它不起作用
可以请任何人解决这个问题吗?我需要正确的正则表达式规则和URL
我需要在datepicker控件中禁用过去的日期.此控件在对话框中打开,我想要禁用过去的日期,以便在选择过去日期时抛出错误.
我有以下代码用于放置rightbarbuttonitem
UIButton* rightbutton = [UIButton buttonWithType:UIButtonTypeCustom];
[rightbutton setBackgroundImage:[UIImage imageNamed:@"share-icon.png"] forState:UIControlStateNormal];
[rightbutton addTarget:self action:@selector(share:) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:rightbutton] autorelease];
Run Code Online (Sandbox Code Playgroud)
但它没有显示任何barbuttonitem.相反,如果我使用以下代码然后出现barbutton项目,但问题是我无法在barbuttonitem上使用此代码设置触摸事件.
UIImageView *iconView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"dashboard-icon.png"]];
UIBarButtonItem *icon = [[UIBarButtonItem alloc] initWithCustomView:iconView];
self.navigationItem.leftBarButtonItem=icon;
[icon release];
[iconView release];
Run Code Online (Sandbox Code Playgroud) 我有我的屏幕的XML结构.我希望我的相对布局与id journeyLandingView在点击某个按钮时向上滑动并显示具有id journeyRootView的视图RelativeLayout,它将从底部向上滑动,因为journeyLandingView将Fill_Parent设置为高度和宽度,因此journeyRootView必须低于journeyLandingView覆盖整个屏幕.我怎样才能做到这一点?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/journeyLandingView">
</RelativeLayout>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/journeyRootView"
android:background="@drawable/root_layer">
</RelativeLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)