小编The*_*One的帖子

如何在Xcode中从A到B获取iPhone iOS 6应用程序的方向?

我想更新iOS <6中使用Google地图的应用.我的应用程序在地图上有很多针脚,当用户点击其中一个时,iPhone会像分享应用程序一样调用地图,以便从当前位置和目标地图应用程序获取方向.对于iOS 6,相同的说明(下面发布)显然打开Safari而不是谷歌地图.我想写一个if-cycle来检查设备上安装的iOS:如果<6,没有任何改变,如果iOS> 6则.....(打开新的苹果地图并获得方向).

有人可以帮帮我吗?

这里是iOS 6之前的Action

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {

    [self.navigationController pushViewController:[[UIViewController alloc] init] animated:YES];


    NSString* addr = [NSString stringWithFormat:@"http://maps.google.com/maps?daddr=%1.6f,%1.6f&saddr=Posizione attuale", view.annotation.coordinate.latitude,view.annotation.coordinate.longitude];

    NSURL* url = [[NSURL alloc] initWithString:[addr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];  
    [[UIApplication sharedApplication] openURL:url];



}
Run Code Online (Sandbox Code Playgroud)

iphone xcode google-maps mkmapview ios6

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

如何在用户做出选择时隐藏UIPickerView

我用以下代码创建了一个自定义UIPickerView

UIPickerView *picker =[[UIPickerView alloc] initWithFrame:CGRectMake(139,50,161,30)];
    picker.delegate=self;
    picker.showsSelectionIndicator=YES;
    picker.hidden=NO;

    [self.view addSubview:picker];
Run Code Online (Sandbox Code Playgroud)

现在我想隐藏pickerView,当用户简单地选择一行时

picker.hidden=YES;
Run Code Online (Sandbox Code Playgroud)

现在:1)如何识别用户的选择,然后隐藏无用的选择器视图?2)我可以在TextField中显示选项吗?用@"选择"?

iphone xcode hide uipickerview

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

如何暂停 Jupyter Notebook 小部件,等待用户输入

在我的笔记本中,我有一个循环,我想在其中要求用户二进制“是”或“否”。在这个选择上,算法应该继续。

for i in range(n_total):
    display.clear_output(wait=True)
    waiting_for_scoring = True
    print("True or False?")
    display.display(widgets.HBox((true_button, false_button)))
    a = true_button.on_click(on_true_button)
    a = false_button.on_click(on_false_button)
    while waiting_for_scoring == True:
        #waiting for user input
        pass
Run Code Online (Sandbox Code Playgroud)

在小部件 HBox 创建之后,如何使循环等待,并等待用户输入(单击按钮)以继续回答新值?

这是我对按钮的两个功能:

def on_true_button(x):
    global waiting_for_scoring
    print('NO!!!!')
    y_new = 1
    waiting_for_scoring = False
    return y_new

def on_false_button(x):
    global waiting_for_scoring
    print('YES')
    y_new = 0
    waiting_for_scoring = False
    return y_new
Run Code Online (Sandbox Code Playgroud)

你能帮我停止循环直到用户按下按钮然后使用这个输入吗?先感谢您

python asynchronous button jupyter-notebook ipywidgets

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

在表视图中搜索栏和搜索显示控制器

我试图实现一个搜索栏,但我没有运气处理这个问题.我真的很感激可以提供任何帮助.我有一个大项目,我有一个表视图,我想在它上面实现一个搜索栏,看看实时过滤.我不使用Storyboard但我使用的是XIB.我添加了以下协议:

<UITableViewDelegate,UITableViewDataSource,UISearchBarDelegate,UISearchDisplayDelegate>
Run Code Online (Sandbox Code Playgroud)

我在@interface中声明了2个数组,第一个用于整个元素,第二个用于过滤的数组:

    NSArray*     OldList;
    NSArray*     filteredList;
Run Code Online (Sandbox Code Playgroud)

然后我设置了行数和节数,然后:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    myClassCell *cell = [tableView dequeueReusableCellWithIdentifier:MYCELLCLASS];
    if (cell == nil)
    {
        cell = [myClassCell newFromNib];
    }
    NSMutableDictionary* elem = nil;
    if (tableView == self.searchDisplayController.searchResultsTableView)
    {
        elem = [filteredList objectAtIndex:indexPath.row];
        if ([elem count]+1 > indexPath.row)
            [cell showValues:elem];
        else
            [cell showValues:nil];
    }
    else
    {
        elem = [OldList objectAtIndex:indexPath.row];
        if ([elem count]+1 > indexPath.row) 
            [cell showValues:elem];
        else
            [cell showValues:nil];
    }
    return cell;
}

-(void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
    NSPredicate *resultPredicate = …
Run Code Online (Sandbox Code Playgroud)

uitableview uisearchbar uisearchdisplaycontroller ios

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