小编cha*_*tur的帖子

在UITableView,iphone中更改滚动条的宽度和颜色

我只能找到是否要显示滚动条或不使用

tableView.showsVerticalScrollIndicator = YES/NO;
Run Code Online (Sandbox Code Playgroud)

但是如何自定义滚动条的颜色,宽度以及其他可能的功能?

任何帮助将不胜感激.

编辑:

我从代码片段中得到了这个想法,其中必须在MKMapKit中找到Google徽标并将其重新定位到某个位置以便它仍然可见.通过以下方法,可以将自定义图像设置为UItbaleview的滚动条.但我没有发现改变滚动条的大小.

-(void) ViewDidLoad
{
UIImageView *testView = [self.tableView.subviews objectAtIndex:1];
    UIImage *Img = [UIImage imageNamed:@"image.png"];
    [testView setImage:Img];
}
Run Code Online (Sandbox Code Playgroud)

编辑:根据Nekto的建议,您可以使用以下来改变宽度.

CGRect frame = testView.frame; 
frame.size.width = 10; //set any value you want.
testView.frame = frame;
Run Code Online (Sandbox Code Playgroud)

iphone scrollbar uitableview

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

为当前位置注释设置canShowCallOut = NO,iPhone

我正在使用当前位置图标的自定义调出(标题和副标题).我尝试了以下来禁用默认注释,但它不起作用.

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
    NSLog(@"viewForAnnotation");
    if ([annotation isKindOfClass:[MKUserLocation class]])
    {
        MKAnnotationView *userLocationView = [mapView viewForAnnotation:annotation];
        userLocationView.canShowCallout = NO;
        NSLog(@"[annotation isKindOfClass:[MKUserLocation class]");
        return nil;
    }

}
Run Code Online (Sandbox Code Playgroud)

只有它的工作方式是

-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)ann
{
    if([ann.annotation isKindOfClass:[MKUserLocation class]] )
    {
       [mymap deselectAnnotation:ann.annotation animated:NO];
    }
}
Run Code Online (Sandbox Code Playgroud)

但它有时会滞后.是否有其他方法可以禁用当前位置注释的默认标注视图?任何帮助将不胜感激.

objective-c mkannotation ios currentlocation

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

将格式化的HTML文本字符串转换为NSString部分

我想解码HTML字符串并将其存储在NSString中.

以下是来自google方向api的响应之一的html字符串.

teststring is Turn <b>right</b> onto <b>Kennington Park Rd/A3</b><div style="font-size:0.9em">Continue to follow A3</div><div style="font-size:0.9em">Entering toll zone in 1.7&nbsp;km at Newington Causeway/A3</div><div style="font-size:0.9em">Go through 2 roundabouts</div>
Run Code Online (Sandbox Code Playgroud)

我想将这个html字符串存储在4个不同NSStrings的Array中,后面有4个NSStrings(删除所有大小颜色的信息)

Turn right onto Kennington Park Rd/A3
Continue to follow A3
Entering toll zone in 1.7 km at Newington Causeway/A3
Go through 2 roundabouts
Run Code Online (Sandbox Code Playgroud)

我使用以下方法将html字符串转换为纯文本.(html_response是服务器的响应,stringByConvertingHTMLToPlainText是自定义类文件中定义的方法)

testString = (NSString*) [html_response stringByConvertingHTMLToPlainText];
NSLog(@"%@",testString);
Run Code Online (Sandbox Code Playgroud)

但它转换整个字符串而不是分割它.控制台的输出是

Turn right onto Kennington Park Rd/A3Continue to follow A3 Entering toll zone in 1.7 km at Newington Causeway/A3 Go through 2 roundabouts …
Run Code Online (Sandbox Code Playgroud)

html iphone decode

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

从CLLocation数组创建GPX文件

我的应用程序需要使用application共享设备中的CLLocations(Route)数组.我没有在此之前使用GPX的经验.GPX是最好的格式吗?如何从给定的CLLocations数组创建GPX文件?Objective C中是否有标准的GPX解析器?从我在网上搜索的内容和SO分别回答这些问题

1.cant say
2. I have seen some webpages converting data of points in GPX format but could not find how they are doing it.
3. No
Run Code Online (Sandbox Code Playgroud)

如果我得到其他答案/意见,我会很高兴.我知道这些都是很多问题.任何帮助或建议将非常感激.

iphone parsing core-location gpx ios

8
推荐指数
2
解决办法
8480
查看次数

无模式数据存储优于存储模式的数据

我想为我的应用选择后端Web服务.阅读这些服务的文档(Parse,Proxomo,Cocoafish,StackMob等)揭示了其中一些提供以无模式形式存储数据,而其他提及必须先指定模式.我理解什么是数据模式,希望无模式易于使用,但想知道每个的优点和缺点.任何解释将不胜感激.

iphone schema android web-services data-storage

7
推荐指数
1
解决办法
408
查看次数

编辑时的UITableView每单元格选择模式

在我UITableView进入编辑模式时,我只想选择几个单元格.我知道UITableView班级有财产allowsSelectionDuringEditing,但这适用于整体UITableView.我没有看到任何相关的委托方法来基于每个单元格进行设置.

我能提出的最佳解决方案是设置allowsSelectionDuringEditingYES.然后,didSelectRowAtIndexPath如果表视图正在编辑,则过滤掉任何不需要的选择.此外,在cellForRowAtIndexPath,将这些单元格更改selectionStyle为"无".

这个问题是进入编辑模式不会重新加载UITableViewCells,所以它们selectionStyle不会改变,直到它们滚动到屏幕外.所以,在setEditing中,我还必须迭代可见单元格并设置它们selectionStyle.

这有效,但我只是想知道这个问题是否有更好/更优雅的解决方案.附上我的代码的基本大纲.任何建议都非常感谢!谢谢.

- (void) tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath {

    if (self.editing && ![self _isUtilityRow:indexPath]) return;
    // Otherwise, do the normal thing...
}

- (UITableViewCell*) tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {

    // UITableViewCell* cell = ...

    if (self.editing && ![self _isUtilityRow:indexPath])
    {
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    else
    {
        cell.selectionStyle = UITableViewCellSelectionStyleBlue;
    }

    return cell;
}

- (void) setEditing:(BOOL)editing animated:(BOOL)animated { …
Run Code Online (Sandbox Code Playgroud)

iphone selection uitableview

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

替换SplitViewController中的TableView

我正在寻找替换UITableViewa的MasterViewController部分UISplitViewController.相反的UITableView,我想只是一个视图,这样我可以放置UIButtons,UILables等它.然后,这些按钮将控制SplitView的DetailView部分中显示的内容.

我在另一个地方问了这个问题,有人建议我创建一个子类UISplitViewController.除了保留DetailViewController.h,.m和.xib以及根据我的喜好编辑MasterViewController.h,.m和.xib之外,这个人并没有给出太多指导.

以下是我采取的步骤:

  • 创建了一个新项目并选择了"Master-Detail Application"
  • 取消选中"使用故事板",这样我就可以获得xib文件.
  • 打开"MasterViewController.xib"
  • 删除"对象"下的"表格视图"
  • 在"对象"中添加了"视图控制器"
  • 将"@interface MasterViewController:UITableViewController"更改为"MasterViewController.h"中的"@interface MasterViewController:UIViewController"
  • 注释掉"MasterViewController.m"下导致问题的任何内容,因为它们引用了TableView的属性,而不再存在.

然后我得到这个错误: - [UIViewController _loadViewFromNibNamed:bundle:]加载"MasterViewController"笔尖但未设置视图插座."

我是在正确的轨道上吗?如果我是,有人可以帮助我解决我得到的错误吗?

否则,如果我遇到这个错误,有人会指出我正确的方向吗?

谢谢!

objective-c uitableview ipad uisplitviewcontroller ios

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

使用 CUDA 求解二维扩散(热)方程

我正在学习 CUDA,试图解决一些标准问题。作为示例,我使用以下代码求解二维扩散方程。但我的结果与标准结果不同,我无法弄清楚。

//kernel definition
__global__ void diffusionSolver(double* A, double * old,int n_x,int n_y)
{

    int i = blockIdx.x * blockDim.x + threadIdx.x;
    int j = blockIdx.y * blockDim.y + threadIdx.y;

    if(i*(n_x-i-1)*j*(n_y-j-1)!=0)
        A[i+n_y*j] = A[i+n_y*j] + (old[i-1+n_y*j]+old[i+1+n_y*j]+
                       old[i+(j-1)*n_y]+old[i+(j+1)*n_y] -4*old[i+n_y*j])/40;


}

int main()
{


    int i,j ,M;
    M = n_y ;
    phi = (double *) malloc( n_x*n_y* sizeof(double));
    phi_old = (double *) malloc( n_x*n_y* sizeof(double));
    dummy = (double *) malloc( n_x*n_y* sizeof(double));
    int iterationMax =10;
    //phase initialization
    for(j=0;j<n_y ;j++)
    {
        for(i=0;i<n_x;i++)
        { …
Run Code Online (Sandbox Code Playgroud)

cuda nvidia differential-equations

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

[NSString stringByReplacingOccurrencesOfString:@"""withString:@""""];

我有一个NSString并希望以CSV格式保存它.正因为如此,我替换所有""".我尝试了以下代码,但编译器报告错误.

newString = [oldstring stringByReplacingOccurrencesOfString:@""" withString:@""""];
Run Code Online (Sandbox Code Playgroud)

oldstring是哪里11th ave, "L&T", Khar.oldstring是根据用户输入设置的.

我怎样才能将newString设置为11th ave, ""L&T"", Khar

任何帮助将不胜感激.

iphone nsstring ios

0
推荐指数
1
解决办法
4243
查看次数