小编Blo*_*der的帖子

从nspasteboard获取字符串

也许这是一个漫漫长夜,但我无法理解如何检查剪贴板中的字符串

我一直在阅读NSPasteboard文档..

有人可以帮助我吗?

clipboard objective-c nspasteboard

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

NSURL中未检测到垂直管道符号

我正在尝试在谷歌词典中进行搜索,但网址包含垂直管道/栏 我的代码无法加载网站

 //http://www.google.com/dictionary?aq=f&langpair=en|en&q=test+test+test&hl=en


if ([mySearchEngineName isEqualToString:@"Google Dictionary"]){
        NSLog(@"Currently searching %@ using %@", mySearchString, mySearchEngineName); 

        NSString *mutateSearchString = [mySearchString stringByReplacingOccurrencesOfString:@" " withString:@"+"];
        NSString *searchURL =[NSString stringWithFormat:@"http://www.google.com/dictionary?aq=f&langpair=en|en&q=%@&hl=en", mutateSearchString];
        NSURL *url = [NSURL URLWithString:searchURL];
        [webBrowser loadRequest:[NSURLRequest requestWithURL:url]];
    }
Run Code Online (Sandbox Code Playgroud)

使用%7C也不起作用..

NSString *searchURL =[NSString stringWithFormat:@"http://www.google.com/dictionary?aq=f&langpair=en%7Cen&q=%@&hl=en", mutateSearchString];
Run Code Online (Sandbox Code Playgroud)

objective-c nsurl

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

两个浮点数之间的随机数生成

我试图在两个浮点数之间生成一个随机数(最大值增加一半)

这是我到目前为止所做的,但它不起作用

    //range
    NSString *minString = [dict objectForKey:@"min"];
    float minRange = [minString floatValue];
    NSString *maxString = [dict objectForKey:@"max"];
    float maxRange = [maxString floatValue];

    NSLog(@"the ORIGINAL range is %f - %f", minRange, maxRange);

    maxRange = maxRange + (maxRange/2);

    //If you want to get a random integer in the range x to y, you can do that by int randomNumber = (arc4random() % y) + x;

    float randomNumber = (arc4random() % maxRange) + minRange; //ERROR: "Invalid operands to binary expression ('float' and …
Run Code Online (Sandbox Code Playgroud)

random floating-point objective-c

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

子视图淡入并淡出帮助

我有一个问题淡出我的子视图.我毫不费力地淡出视图但渐渐消失.只是放下视图.

-(void)flipToReview {
ReviewViewController *reviewVariable = [[ReviewViewController alloc] initWithNibName:@"ReviewViewController" bundle:nil];
[self setReviewViewController:reviewVariable];
self.ReviewViewController.view.alpha =0;
[UIView beginAnimations:@"flipview" context:nil]; 
[UIView setAnimationDuration:0.3];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:_window cache:YES];
[reviewVariable release];    
[self.window addSubview:self.ReviewViewController.view];
self.ReviewViewController.view.alpha =1;

[UIView commitAnimations];
}


-(void)flipBackFromReview {
//   self.ReviewViewController.view.alpha = 1;

[UIView beginAnimations:@"trip" context:nil]; 
[UIView setAnimationDuration:0.3];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];

[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:_window cache:NO];
self.ReviewViewController.view.alpha = 0;
[self.ReviewViewController.view removeFromSuperview];
[UIView commitAnimations];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
[self.ReviewViewController.view setHidden:1];
NSLog(@"remove subview"); 
}
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c uiview

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

nsstring stringByReplacingOccurrencesOfString挫折?

我想替换/删除这个:

[\"

来自字符串bump3

NSString *bump5 = [bump3 stringByReplacingOccurrencesOfString:@"[\\"" withString:@""];
Run Code Online (Sandbox Code Playgroud)

错误:缺少终止""字符.

有人可以帮帮我吗?从盯着这个屏幕看,我的大脑已经被炒得很厉害了.

更新:

偶然想出来并试了一下!

@"\"是单个反斜杠@"\\"是双反斜杠

所以我使用了NSString*bump5 = [bump3 stringByReplacingOccurrencesOfString:@"[\\""withString:@""];

xcode replace nsstring

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

如果不包含http或https,则nsurl不会加载站点

我有一个文本框,我可以在其中键入URL.问题是如果我只是输入'cnn.com'或任何前面没有'http://'的网站,页面就不会加载.有没有办法来解决这个问题?

我搜索了苹果文档,但找不到我正在寻找的帮助.

我的代码:

NSString *zzz = URLbox.text;

NSURL *url = [NSURL URLWithString:zzz];
[webBrowser loadRequest:[NSURLRequest requestWithURL:url]];
Run Code Online (Sandbox Code Playgroud)

objective-c nsurl nsurlrequest

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