小编D-e*_*per的帖子

设置UISegmentedControl的背景图像

所以我有以下代码来设置分段控件背景颜色:

UISegmentedControl * segmentedCtrl = [[UISegmentedControl alloc] initWithFrame:CGRectMake(0, 0, 150, 35)];
[segmentedCtrl setBackgroundImage:[UIImage imageNamed:@"btn-gradient-brown"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[segmentedCtrl setBackgroundImage:[UIImage imageNamed:@"btn-gradient-brown"] forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
[segmentedCtrl insertSegmentWithImage:[UIImage imageNamed:@"icon-home.png"] atIndex:0 animated:NO];
[segmentedCtrl insertSegmentWithImage:[UIImage imageNamed:@"icon-star.png"] atIndex:1 animated:NO];
Run Code Online (Sandbox Code Playgroud)

一切正常,但是当我点击片段时,我可以看到突出显示的蓝色按钮.如何禁用此突出显示?这是我的问题的截图:

在此输入图像描述

iphone objective-c uisegmentedcontrol ipad ios

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

模态视图控制器无法在横向模式下启动

我有一个基于导航的应用程序,它有一个详细视图(UIWebView),在UIToolbar的底部有操作按钮.我想在按下"音符"按钮时添加"音符".当webview处于纵向模式时,一切正常.我按下音符按钮,模态视图打开很好,效果很好.

当webview处于横向模式时,会出现此问题.如果我按下音符按钮,所有打开模态视图的代码都会被调用,但我得到的只是一个白色屏幕.一条评论:如果我以纵向打开模态视图然后旋转设备,它会精细旋转到横向模式.它只是无法在横向模式下正确打开.

我有另一个按钮,它会调出具有相同行为的邮件编辑器.这是我的UIWebViewController中的代码:

- (IBAction)addNotes:(id)sender 
{
    NotesViewController *notesViewController;

    // create the view controller and set it as the root view of a new navigation
    // controller

    notesViewController = [[NotesViewController alloc] initWithPrimaryKey:self.record.primaryKey];
    UINavigationController *newNavigationController =  
    [[UINavigationController alloc] initWithRootViewController:notesViewController];

    // present the navigation controller modally

    [self presentModalViewController:newNavigationController animated:YES];
    [notesViewController release]; 
    [self.view setNeedsDisplay]; // not sure if I need this!  I was trying different things...
    [self.devotionText setNeedsDisplay]; // ditto...
    [newNavigationController release];
}
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?我尝试过各种不同的东西都无济于事.我只是得到一个没有导航栏的白色屏幕(尽管顶部有一个状态栏).

iphone xcode modalviewcontroller

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

在地图应用iOS上获取方向功能

我想在iOS默认Map App中的两个位置之间实现get direction功能,我试过这个

Class itemClass = [MKMapItem class];
if (itemClass && [itemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)]) {
    // Use iOS 6 maps
    NSString *latString = @"23.0300";
    NSString *longString = @"72.5800";

    CLLocationCoordinate2D  ctrpoint;
    ctrpoint.latitude = [latString doubleValue];
    ctrpoint.longitude = [longString doubleValue];

    MKPlacemark *placemark2 = [[MKPlacemark alloc] initWithCoordinate:ctrpoint addressDictionary:nil];
    MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark2];
    [mapItem openInMapsWithLaunchOptions:nil];
}
Run Code Online (Sandbox Code Playgroud)

但它显示方向错误如下:

获取方向错误

我甚至打开了地图应用程序,找到了我当前的位置,在离我所在位置最近的地图上添加了一个图钉,并且获取方向仍然无效.

此外,"总之,即使在本机应用程序中,Get Direction也无法正常工作"任何人都可以帮助我实现这一目标吗?

iphone mapkit mkmapview ios

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