小编Dac*_*hmt的帖子

使用MapKit ios的渐变折线

我正在尝试使用叠加(MKOverlay)跟踪MKMapView上的路线.但是,根据当前的速度,如果颜色正在变化(例如,如果用户从65mph驱动到30mph),我想要在跟踪路线时使用渐变来执行类似Nike应用程序的操作(例如,从绿色变为橙色).

这是我想要的截图:

渐变叠加图像

因此,每隔20米,我使用以下方法添加从旧坐标到新坐标的叠加:

// Create a c array of points. 
MKMapPoint *pointsArray = malloc(sizeof(CLLocationCoordinate2D) * 2);

// Create 2 points.
MKMapPoint startPoint = MKMapPointForCoordinate(CLLocationCoordinate2DMake(oldLatitude, oldLongitude));
MKMapPoint endPoint = MKMapPointForCoordinate(CLLocationCoordinate2DMake(newLatitude, newLongitude));

// Fill the array.
pointsArray[0] = startPoint;
pointsArray[1] = endPoint;

// Erase polyline and polyline view if not nil.
if (self.routeLine != nil)
    self.routeLine = nil;

if (self.routeLineView != nil)
    self.routeLineView = nil;

// Create the polyline based on the array of points.
self.routeLine = [MKPolyline polylineWithPoints:pointsArray count:2];

// Add …
Run Code Online (Sandbox Code Playgroud)

overlay gradient mapkit mkmapview ios

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

Python类装饰器参数

我正在尝试将可选参数传递给python中的类装饰器.在我目前的代码下面:

class Cache(object):
    def __init__(self, function, max_hits=10, timeout=5):
        self.function = function
        self.max_hits = max_hits
        self.timeout = timeout
        self.cache = {}

    def __call__(self, *args):
        # Here the code returning the correct thing.


@Cache
def double(x):
    return x * 2

@Cache(max_hits=100, timeout=50)
def double(x):
    return x * 2
Run Code Online (Sandbox Code Playgroud)

第二个带有参数的装饰器覆盖默认的(max_hits=10, timeout=5在我的__init__函数中),不起作用,我得到了异常TypeError: __init__() takes at least 2 arguments (3 given).我尝试了许多解决方案,并阅读了有关它的文章,但在这里我仍然无法使它工作.

有什么想法解决这个问题?谢谢!

python arguments decorator

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

Bitbucket自述文件降序排序列表在代码块后重新启动

我在Bitbucket上使用Markdown作为我的README.md并在代码块之后实现我的有序列表重启为1.这是我的文字的一个例子:

1. Download VirtualBox
2. Download Vagrant
3. Clone the repository

> git clone URL

4. Go to repository folder

> cd /my_repo

5. Setup your dev environment
Run Code Online (Sandbox Code Playgroud)

4号和5号都1.在我的README中,这不是我想要的.也许我应该使用``而不是?结果将不会是相同的风格,但如果我的列表保持编号,它至少会更好.

有解决方案吗

markdown bitbucket

11
推荐指数
2
解决办法
2612
查看次数

iOS删除MKMapView覆盖不起作用

我想在一点上删除我的地图的所有叠加,我尝试了不同的方式,但它永远不会工作.

最后一次尝试我做了[self.mapView removeOverlays:self.mapView.overlays];它仍然无法正常工作.知道如何删除那些叠加层吗?

谢谢.

更新1

我有错误: malloc: *** error for object 0x5adc0c0: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug

我想我知道为什么,但是真的不知道如何解决它...当我需要在mapView上绘制另一行时,这是代码:

// Create a c array of points. 
MKMapPoint *pointsArray = malloc(sizeof(CLLocationCoordinate2D) * 2);

// Create 2 points.
MKMapPoint startPoint = MKMapPointForCoordinate(CLLocationCoordinate2DMake(oldLatitude, oldLongitude));
MKMapPoint endPoint = MKMapPointForCoordinate(CLLocationCoordinate2DMake(newLatitude, newLongitude));

// Fill the array.
pointsArray[0] = startPoint;
pointsArray[1] = endPoint;

// Erase polyline and polyline view if not nil.
if (self.routeLine != nil) { …
Run Code Online (Sandbox Code Playgroud)

overlay mkmapview ios android-mapview

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

UITableView阴影顶部和底部

在我的一个视图中,我使用的是UIWebView,我喜欢背景视图顶部和底部的默认阴影效果,以及滚动区域的顶部和底部.

在时钟应用程序中有相同的,具有自定义背景(蓝色线与世界地图)所以它可以使用UITableView我也猜...

以下是我对Web视图的看法,并且我想添加到表视图中.我的网页浏览量:

在此输入图像描述

所以我在这里添加了一个自定义背景(浅灰色纹理).这是在我添加相同背景的另一个视图下方,但正如您所看到的那样没有阴影......我猜这不是UIScrollView的内置效果.有没有办法用表视图做同样的事情?

我的表格视图:

在此输入图像描述

更新1:

我发现这篇很棒的文章UITableView Shadows,但是视图底部没有阴影.

iphone gradient uitableview uiscrollview

6
推荐指数
1
解决办法
5528
查看次数

BlackBerry - 自定义菜单工具栏

我是BlackBerry编程的初学者,我需要在我的应用程序中用自定义菜单替换默认菜单(当你按下菜单按钮时).最好的描述是我想要与BlackBerry的WeatherEye应用程序相同的结果...

alt text http://www.blackberrybing.com/resource/pics/201002/WeatherEye-OS-45.jpg

我知道如何创建默认菜单,但这个我不知道!谢谢,

user-interface blackberry menu custom-controls

5
推荐指数
1
解决办法
6021
查看次数

PHP MySQL从GPS获取半径用户位置的位置

例如,我在我的数据库中发生汽车事故.这些事件具有纬度和经度.在使用GPS的手机上,我用坐标获取用户的位置.如果他周围有事件,用户可以选择他想知道的半径.所以我想说他想知道身边2英里的事件.

所以我从手机发送用户的纬度,经度和他选择的半径到网络服务.我需要进行SQL查询以获取用户周围2英里的事件.

你知道怎么做吗?

php mysql location coordinates

5
推荐指数
1
解决办法
7959
查看次数

iOS Xcode 4属性访问

我最近切换到Xcode 4,我真的不明白这种写入访问器的新方法.例如,在创建新项目时自动生成的应用程序委托类中,该window对象不是以@interface这种方式声明的:

@property (nonatomic, retain) IBOutlet UIWindow *window;
Run Code Online (Sandbox Code Playgroud)

然后,在实现文件中,我们有了@synthesize window=_window;.在函数中,我们有self.windowOR _window.

例如:

[self.window makeKeyAndVisible]; // in didFinishLaunchingWithOptions function
[_window release]; // in dealloc function
Run Code Online (Sandbox Code Playgroud)

你能解释我的区别,为什么有没有在@interface,所以我们做@synthesize window=_window;的,而不是@synthesize window;和之间有什么区别self.window_window,我的意思是,当我必须打电话给其中一个比另一个更?

我有点迷失了,感觉就像新的代码,我正在努力做同样的工作......

谢谢!

xcode accessor ios xcode4

5
推荐指数
1
解决办法
3532
查看次数

NSDecimalNumber用于iPhone上的大数量操作

我需要在我的应用程序中使用大数字来提高精度,浮动或双重是不够的.我也有int和float数字,我必须对它们进行操作.

我认为NSDecimalNumber对我需要的精度有好处,但我想用其他类型的数字进行操作,这是复杂的公式.因此,当你有很多东西时,我认为使用这个类来执行复杂的公式(使用函数decimalWith ...或decimalBy ......太复杂)是不合适的.

有没有人知道使用什么来轻松操作大数字,并用不同的类型(float,decimal,int)对它们进行操作?

谢谢.

iphone operations decimal objective-c bigdecimal

4
推荐指数
1
解决办法
2409
查看次数

Django注册登录重定向

使用django-registration,我在settings.py中:

LOGIN_REDIRECT_URL = '/'
Run Code Online (Sandbox Code Playgroud)

当我试图访问一个页面(退出)时http://localhost:8000/surfboards/current/,我被重定向到http://localhost:8000/accounts/login/?next=/surfboards/current/

在这种情况下,如果next指定了参数,我希望在登录成功后重定向到此页面,而不是默认值LOGIN_REDIRECT_URL.

现在,我总是被重定向到http://localhost:8000/,只有在next没有指定时才是我想要的.

谢谢,

django redirect login django-registration django-1.5

4
推荐指数
1
解决办法
3944
查看次数

黑莓编码的MD5与MD5中的MD5不同

我将我的密码用MD#编码在C#中并插入我的数据库中.

MD5 MD5Hasher = MD5.Create();
byte[] PasswordHash = MD5Hasher.ComputeHash(Encoding.Unicode.GetBytes(PasswordText.Value));
Run Code Online (Sandbox Code Playgroud)

PasswordHash插入原样,看起来就像0x09C09E5B52580E477514FA ..........例如.

在黑莓应用程序中,我获取密码,想要对其进行编码以将其传递给将比较两个散列密码的Web服务.问题是我的结果与我在Blackberry应用程序中创建的MD5不同.

password = Crypto.encodeStringMD5(password);
Run Code Online (Sandbox Code Playgroud)

然后在我的功能下面:

    public static String encodeStringMD5(String s) throws Exception {
    byte[] bytes = s.getBytes();
    MD5Digest digest = new MD5Digest();
    digest.update(bytes, 0, bytes.length);
    int length = digest.getDigestLength();
    byte[] md5 = new byte[length];
    digest.getDigest(md5, 0, true);
    return convertToHex(md5);
}

private static String convertToHex(byte[] data) {
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < data.length; i++) {
        int halfbyte = (data[i] >>> 4) …
Run Code Online (Sandbox Code Playgroud)

encoding md5 blackberry

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

iPhone CLLocationManager每0.5秒更新一次

对于从GPS进行大量计算的应用程序,我需要每0.5秒获得纬度/经度和速度,以便非常准确并避免延迟.

我在用:

  • [locationManager setDesiredAccuracy:kCLLocationAccuracyBestForNavigation];
  • - locationManager:didUpdateToLocation:fromLocation:函数将值存储在3个变量中:newLatitude,newLongitudenewSpeed
  • NSTimer每0.5秒调用一次函数的对象.

请参阅下面的Excel生成的图表,表示18秒内的纬度值:

纬度值在18秒内

我们可以清楚地看到我们每秒都有位置更新,而不是每隔0.5秒就有所需.我在办公室里做样品,所以我的速度在0到65英里/小时之间.因此,当我驱动50MPH时,我应该每隔0.5秒从iPhone获得不同的lat/lon/speed值?

如果您对该CLLocationManager对象的准确性有任何了解,请告诉我如何每0.5秒获取一次这些位置更新.

谢谢!

iphone cllocationmanager

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

iPhone奇怪的行为UITableView细胞

我有一个包含3个部分的设置视图.某些单元格具有不同的样式:默认或值1.当我快速向上或向下滑动,或更改视图并返回时,应该在单元格中的文本(例如,我的单元格中的detailTextLabel与StyleValue1)不再在此处,或者有时在上方或下方的单元格中.这是截图:第一个是正常状态,第二个是来自Version的detailTextLabel进入上面的单元格,第三个是Measurement System detailTextLabel消失了......

细胞的正常行为 在此输入图像描述 在此输入图像描述

这是我的代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        if (indexPath.section == 1 && indexPath.row == 0) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
        }
        else if (indexPath.section == 2 && indexPath.row == 2) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
        }
        else {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        }
    }

    // Selection style.
    cell.selectionStyle = UITableViewCellSelectionStyleGray;

    // Vehicles …
Run Code Online (Sandbox Code Playgroud)

iphone uitableview ios detailtextlabel

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