小编adi*_*dit的帖子

设置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万
查看次数

如何获取URL的标题

我有一个URL,我将在ModalViewController中显示URL.我想在导航栏中设置此URL的标题.

在ModalViewController内部,我有一个UIWebView来显示站点.有没有办法通过UIWebView提取这个网站的标题?做了一些研究,似乎我想在里面使用一些javascript (void)webViewDidFinishLoad:(UIWebView *)webView 不确定它是如何工作的.

objective-c uinavigationbar uiwebview ios

9
推荐指数
1
解决办法
3523
查看次数

在范围内的NSMutableArray中删除对象

我试图删除从索引5开始到列表末尾的数组中的对象.我有一个for循环来做这个,但现在我发现了

 - (void)removeObject:(id)anObject inRange:(NSRange)aRange
Run Code Online (Sandbox Code Playgroud)

问题是这里的anObject是什么?据我所知,我只需要射程

iphone objective-c nsmutablearray ipad ios

9
推荐指数
1
解决办法
8824
查看次数

three20和iOS 6无法正常工作

我只是尝试了一个我的项目,其中包含Three20,似乎它没有编译/给我构建错误.看起来像是因为某些UITouch界面已经改变了.不知道有没有快速解决方法吗?

似乎这里是问题:

UITouch ivars已被删除iOS 6 SDK标头:UIViewAdditions中的私有API访问打破了iOS 6上的构建.

iphone objective-c three20 ipad ios

9
推荐指数
1
解决办法
5452
查看次数

UISplitViewController纵向模式缺少UIBarButtonItem

我有一个带有UISplitViewController的应用程序,当我在potrait模式下启动应用程序时,它缺少"Group"UIBarButtonItem.我需要转向横向模式并返回potrait以使其显示.当我以横向模式启动时它就在那里.这是一些明确的屏幕截图:

这是在纵向模式下启动应用程序的时间 在此输入图像描述

从纵向模式旋转后,这是横向模式: 在此输入图像描述

这是从横向模式旋转回纵向模式后:在此输入图像描述

objective-c ipad uisplitviewcontroller

8
推荐指数
1
解决办法
3992
查看次数

顺序运行CABasicAnimation

如何在另一个CABasicAnimation完成后运行一个CABasicAnimation?换句话说,顺序.我添加了第二个动画的开始时间,但似乎第二个动画没有被执行:

CABasicAnimation * appearance =[CABasicAnimation animationWithKeyPath:@"transform.translation.y"];
    appearance.duration = 0.5;
    appearance.fromValue = [NSNumber numberWithFloat:0];
    appearance.toValue = [NSNumber numberWithFloat:340];
    appearance.repeatCount = 1;
    appearance.fillMode = kCAFillModeForwards;
    appearance.removedOnCompletion = NO;
    [notif.layer addAnimation:appearance forKey:@"transform.translation.y"];



    CABasicAnimation * theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.translation.y"];
    theAnimation.duration = 0.5;
    theAnimation.fromValue = [NSNumber numberWithFloat:0];
    theAnimation.toValue = [NSNumber numberWithFloat:10];
    theAnimation.repeatCount = 3;
    theAnimation.autoreverses = YES;
    theAnimation.fillMode = kCAFillModeForwards;
    theAnimation.removedOnCompletion = NO;
    theAnimation.beginTime = appearance.beginTime + appearance.duration;
    [notif.layer addAnimation:theAnimation forKey:@"transform.translation.y"];
Run Code Online (Sandbox Code Playgroud)

知道为什么吗?

iphone core-animation objective-c cabasicanimation ios

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

NSURLCache没有缓存

所以我有子类NSURLCache,每次我调用loadHTMLFromString:storeCachedRequest:forRequest:然后cachedResponseForRequest:.这就是我所拥有的:

- (NSCachedURLResponse *)cachedResponseForRequest:(NSURLRequest *)request
{
    NSString *pathString = [[request URL] absoluteString];

    NSCachedURLResponse * response = [super cachedResponseForRequest:request];
    if (response != nil)
        return response;
    else {
        NSString* myString= @"testing";

        NSData* data=[myString dataUsingEncoding: NSASCIIStringEncoding ];

        //
        // Create the cacheable response
        //
        NSURLResponse *response =
        [[[NSURLResponse alloc]
          initWithURL:[request URL]
          MIMEType:[self mimeTypeForPath:pathString]
          expectedContentLength:[data length]
          textEncodingName:nil]
         autorelease];
        NSCachedURLResponse * cachedResponse =
        [[[NSCachedURLResponse alloc] initWithResponse:response data:data] autorelease];

        [self storeCachedResponse:cachedResponse forRequest:request] ;

        //NSLog(@"DEFAULT CACHE WITH URL %@", …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c nsurlcache ipad

8
推荐指数
1
解决办法
2909
查看次数

javascript函数以获取html中的所有图像

我想有一个javascript函数基本上返回一个页面中所有img src的数组,我该怎么做?

javascript

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

改变歌剧迷你的占位符

我目前正在使用此代码替换不可用的占位符功能.我在jQuery上有一个点击监听器,它改变了占位符文本:

$('.contact-type').change(function(event) {
    $contactInfo = $(this).closest('div').prev().find('#contact-info');
    $contactInfo.removeClass();
    $contactInfo.addClass('form-control input-lg');

    $contactInfo.addClass('validate[required,custom[line]]');
    $contactInfo.attr("placeholder", "LINE ID");
})
Run Code Online (Sandbox Code Playgroud)

问题是当使用jquery占位符时,我更改了占位符文本然后调用了$('input, textarea').placeholder();.新的占位符不会改变.如何在值更改时更改占位符?

html javascript jquery html5 opera-mini

8
推荐指数
1
解决办法
745
查看次数

如何用颜色填写drawRect

我有一个drawRect,我想填写用某种颜色指定的矩形.我该怎么办?到目前为止,我尝试了以下内容:

- (void)drawRect:(CGRect)rect
{
        CGContextRef context = UIGraphicsGetCurrentContext();
         CGContextSetFillColorWithColor(context, [UIColor colorWithWhite:29/255.f alpha:1.0].CGColor);
CGContextFillRect(context, rect);
}
Run Code Online (Sandbox Code Playgroud)

这似乎不起作用

iphone objective-c ipad ios

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